use of org.jboss.as.patching.metadata.MiscContentItem in project wildfly-core by wildfly.
the class Location method hashCode.
static int hashCode(final ContentItem item) {
final ContentType type = item.getContentType();
switch(type) {
case MODULE:
case BUNDLE:
final ModuleItem module = (ModuleItem) item;
final String[] path = module.getName().split("\\.");
return hashCode(type.toString(), module.getSlot(), path);
case MISC:
final MiscContentItem misc = (MiscContentItem) item;
return hashCode(type.toString(), misc.getName(), misc.getPath());
default:
throw new IllegalStateException();
}
}
use of org.jboss.as.patching.metadata.MiscContentItem in project wildfly-core by wildfly.
the class ContentPolicyBuilderImpl method createPolicy.
@Override
public ContentVerificationPolicy createPolicy() {
return new ContentVerificationPolicy() {
@Override
public boolean ignoreContentValidation(ContentItem item) {
final ContentType type = item.getContentType();
if (type == ContentType.MODULE || type == ContentType.BUNDLE) {
return ignoreModulesChanges || overrideAll;
}
final MiscContentItem misc = (MiscContentItem) item;
final String path = misc.getRelativePath();
if (override.contains(path)) {
return true;
}
// Preserve should skip content verification
if (preserve.contains(path)) {
return true;
}
return overrideAll;
}
@Override
public boolean preserveExisting(ContentItem item) {
final ContentType type = item.getContentType();
if (type == ContentType.MISC) {
final MiscContentItem misc = (MiscContentItem) item;
final String path = misc.getRelativePath();
return preserve.contains(path);
}
return false;
}
};
}
use of org.jboss.as.patching.metadata.MiscContentItem in project wildfly-core by wildfly.
the class PatchingTestUtil method updateModulesJar.
static ContentModification updateModulesJar(final File installation, final File patchDir) throws IOException {
final String fileName = "jboss-modules.jar";
final File source = new File(installation, fileName);
final File misc = new File(patchDir, "misc");
misc.mkdirs();
final File target = new File(misc, fileName);
updateJar(source, target);
final byte[] sourceHash = HashUtils.hashFile(source);
final byte[] targetHash = HashUtils.hashFile(target);
assert !Arrays.equals(sourceHash, targetHash);
final MiscContentItem item = new MiscContentItem(fileName, new String[0], targetHash, false, false);
return new ContentModification(item, sourceHash, ModificationType.MODIFY);
}
use of org.jboss.as.patching.metadata.MiscContentItem in project wildfly-core by wildfly.
the class ContentModificationUtils method removeMisc.
public static ContentModification removeMisc(File existingFile, String... fileSegments) throws IOException {
byte[] existingHash = hashFile(existingFile);
String[] subdir = new String[0];
if (fileSegments.length > 0) {
subdir = new String[fileSegments.length - 1];
System.arraycopy(fileSegments, 0, subdir, 0, fileSegments.length - 1);
}
ContentModification fileRemoved = new ContentModification(new MiscContentItem(existingFile.getName(), subdir, NO_CONTENT), existingHash, REMOVE);
return fileRemoved;
}
use of org.jboss.as.patching.metadata.MiscContentItem in project wildfly-core by wildfly.
the class ContentModificationUtils method modifyMisc.
public static ContentModification modifyMisc(File patchDir, String patchElementID, String modifiedContent, byte[] existingHash, String... fileSegments) throws IOException {
File miscDir = newFile(patchDir, patchElementID, MISC);
File modifiedFile = touch(miscDir, fileSegments);
dump(modifiedFile, modifiedContent);
byte[] modifiedHash = hashFile(modifiedFile);
String[] subdir = new String[0];
if (fileSegments.length > 0) {
subdir = new String[fileSegments.length - 1];
System.arraycopy(fileSegments, 0, subdir, 0, fileSegments.length - 1);
}
ContentModification fileUpdated = new ContentModification(new MiscContentItem(modifiedFile.getName(), subdir, modifiedHash), existingHash, MODIFY);
return fileUpdated;
}
Aggregations