use of org.jboss.as.patching.metadata.ContentType in project wildfly-core by wildfly.
the class PatchStepAssertions method assertContentModification.
static void assertContentModification(final String patchID, final PatchableTarget target, final ContentModification modification) {
final ContentItem item = modification.getItem();
final ContentType contentType = item.getContentType();
switch(contentType) {
case MODULE:
assertModule(patchID, target, (ModuleItem) item);
break;
case BUNDLE:
break;
case MISC:
final File home = target.getDirectoryStructure().getInstalledImage().getJbossHome();
final ModificationCondition condition = modification.getCondition();
if (condition != null) {
if (condition instanceof ModificationCondition.ExistsCondition) {
final ContentItem requiredItem = ((ModificationCondition.ExistsCondition) condition).getContentItem();
File requiredFile;
switch(requiredItem.getContentType()) {
case MISC:
requiredFile = PatchContentLoader.getMiscPath(home, (MiscContentItem) requiredItem);
break;
case MODULE:
case BUNDLE:
default:
throw new IllegalStateException("Unsupported content type");
}
if (!requiredFile.exists()) {
final File file = PatchContentLoader.getMiscPath(home, (MiscContentItem) item);
Assert.assertFalse(file.exists());
return;
}
}
}
assertMisc(home, modification.getType(), (MiscContentItem) item);
break;
default:
Assert.fail();
}
}
use of org.jboss.as.patching.metadata.ContentType 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.ContentType 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.ContentType in project wildfly-core by wildfly.
the class PatchOperationTarget method formatFailedResponse.
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());
}
}
Aggregations