Tabnine Logo
PatchUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
PatchUtils
in
org.jboss.as.patching.runner

Best Java code snippets using org.jboss.as.patching.runner.PatchUtils (Showing top 20 results out of 315)

origin: org.wildfly.core/wildfly-patching

public static List<String> readRefs(final Properties properties) {
  return readRefs(properties, Constants.PATCHES);
}
origin: wildfly/wildfly-core

  public static byte[] getAbsentModuleContentHash(final ModuleItem item) throws IOException {
    final byte[] content = getAbsentModuleContent(item);
    return HashUtils.hashBytes(content);
  }
}
origin: org.wildfly.core/wildfly-patching

  public void renameFiles() throws IOException {
    List<String> failures = PatchUtils.readRefs(renamingFailureMarker);
    for(String path : failures) {
      File toBeRenamed = new File(path);
      if(toBeRenamed.exists()) {
        if(!toBeRenamed.renameTo(PatchUtils.getRenamedFileName(toBeRenamed))) {
          log.cannotDeleteFile(path);
        }
      }
    }
    renamingFailureMarker.delete();
  }
}
origin: org.wildfly.core/wildfly-patching

public static TargetInfo loadTargetInfo(final Properties properties, final DirectoryStructure structure) {
  final String ref = PatchUtils.readRef(properties, Constants.CUMULATIVE);
  final List<String> patches = PatchUtils.readRefs(properties);
  return new TargetInfoImpl(properties, ref, patches, structure);
}
origin: org.wildfly.core/wildfly-patching

protected void persist(final String cumulativeID, final List<String> patches, final Properties properties) throws IOException {
  assert cumulativeID != null;
  // Create the parent
  IoUtils.mkdir(structure.getInstallationInfo().getParentFile());
  final List<String> consolidate = new ArrayList<String>();
  consolidate.addAll(patches);
  if (!Constants.BASE.equals(cumulativeID)) {
    consolidate.add(cumulativeID);
  }
  if (structure.getModuleRoot() != null) {
    final File overlays = new File(structure.getModuleRoot(), Constants.OVERLAYS);
    final File refs = new File(overlays, Constants.OVERLAYS);
    PatchUtils.writeRefs(refs, consolidate);
  }
  // Update the properties
  properties.put(Constants.CUMULATIVE, cumulativeID);
  properties.put(Constants.PATCHES, PatchUtils.asString(patches));
  if(version != null) {
    properties.put(Constants.CURRENT_VERSION, version);
  }
  // Write layer.conf
  PatchUtils.writeProperties(structure.getInstallationInfo(), properties);
}
origin: org.wildfly.core/wildfly-patching

final Properties properties = PatchUtils.loadProperties(identity.getDirectoryStructure().getInstallationInfo());
final List<String> allPatches = PatchUtils.readRefs(properties, Constants.ALL_PATCHES);
origin: org.wildfly.core/wildfly-patching

@Override
public File[] getTargetModulePath() {
  // We need the updated state for invalidating one-off patches
  // When applying the overlay directory should not exist yet
  final PatchableTarget.TargetInfo updated = mode == Mode.APPLY ? delegate : delegate.getModifiedState();
  return PatchUtils.getModulePath(delegate.getDirectoryStructure(), updated);
}
origin: wildfly/wildfly-core

@Test
public void testAddRemove() throws Exception {
  final Patch cp1 = generateCP("base", "cp1", ModificationType.ADD);
  final Patch cp2 = generateCP("cp1", "cp2", ModificationType.REMOVE);
  final Patch merged = PatchMerger.merge(cp1, cp2);
  assertEquals("cp2", merged.getPatchId());
  assertEquals("cp2" + " description", merged.getDescription());
  final IdentityUpgrade identity = merged.getIdentity().forType(PatchType.CUMULATIVE, Identity.IdentityUpgrade.class);
  assertEquals("base", identity.getVersion());
  assertEquals("cp2", identity.getResultingVersion());
  assertEquals(PatchType.CUMULATIVE, identity.getPatchType());
  final List<PatchElement> elements = merged.getElements();
  assertEquals(1, elements.size());
  final PatchElement e = elements.get(0);
  assertEquals("base-" + "cp2", e.getId());
  final PatchElementProvider provider = e.getProvider();
  assertEquals("base", provider.getName());
  assertEquals(PatchType.CUMULATIVE, provider.getPatchType());
  assertEquals(LayerType.Layer, provider.getLayerType());
  //assertEquals(0, e.getModifications().size());
  // for modules remove is effectively a modify which changes the module xml to indicate an absent module
  // so, it will remain an add of an absent module
  assertEquals(1, e.getModifications().size());
  final ContentModification mod = e.getModifications().iterator().next();
  assertEquals(ModificationType.ADD, mod.getType());
  Assert.assertArrayEquals(PatchUtils.getAbsentModuleContentHash((ModuleItem) mod.getItem()), mod.getItem().getContentHash());
}
origin: org.wildfly.core/wildfly-patching

@Override
public void finishPatch(final Patch processedPatch, final RollbackPatch rollbackPatch, final IdentityPatchContext context) throws Exception {
  final File historyDir = structure.getInstalledImage().getPatchHistoryDir(patchId);
  if (!historyDir.exists()) {
    historyDir.mkdirs();
  }
  // Backup the current active patch Info
  final File timestamp = new File(historyDir, Constants.TIMESTAMP);
  PatchUtils.writeRef(timestamp, generateTimestamp());
  // Persist the processed patch, which contains the records of changes
  final File backupPatchXml = new File(historyDir, PatchXml.PATCH_XML);
  IdentityPatchContext.writePatch(processedPatch, backupPatchXml);
  // Persist the rollback.xml in the history directory
  final File rollbackPatchXml = new File(historyDir, Constants.ROLLBACK_XML);
  IdentityPatchContext.writePatch(rollbackPatch, rollbackPatchXml);
  // Backup the configuration
  context.backupConfiguration();
}
origin: org.wildfly.core/wildfly-patching

static String readRef(final InputStream is) throws IOException {
  final StringBuffer buffer = new StringBuffer();
  readLine(is, buffer);
  return buffer.toString();
}
origin: org.wildfly.core/wildfly-patching

@Override
protected void persist() throws IOException {
  getMutableProperties().put(Constants.ALL_PATCHES, PatchUtils.asString(allPatches));
  super.persist();
}
origin: wildfly/wildfly-core

private static void backup(final IdentityPatchContext context, final File file) {
  String fileName = file.getName();
  if (fileName.endsWith(JAR_EXT)) {
    File targetFile = PatchUtils.getRenamedFileName(file);
    if (!file.renameTo(targetFile)) {
      if (context != null) {
        context.failedToRenameFile(file, targetFile);
      } else {
        throw PatchLogger.ROOT_LOGGER.cannotRenameFileDuringBackup(file.getAbsolutePath());
      }
    }
  }
}
origin: wildfly/wildfly-core

/**
 * Process the layers.conf file.
 *
 * @param repoRoot the root
 * @return the layers conf
 * @throws java.io.IOException
 */
public static LayersConfig getLayersConfig(final File repoRoot) throws IOException {
  final File layersList = new File(repoRoot, LAYERS_CONF);
  if (!layersList.exists()) {
    return new LayersConfig();
  }
  final Properties properties = PatchUtils.loadProperties(layersList);
  return new LayersConfig(properties);
}
origin: org.wildfly.core/wildfly-patching

@Override
public File[] getTargetBundlePath() {
  // We need the updated state for invalidating one-off patches
  // When applying the overlay directory should not exist yet
  final PatchableTarget.TargetInfo updated = mode == Mode.APPLY ? delegate : delegate.getModifiedState();
  return PatchUtils.getBundlePath(delegate.getDirectoryStructure(), updated);
}
origin: wildfly/wildfly-core

public static TargetInfo loadTargetInfo(final Properties properties, final DirectoryStructure structure) {
  final String ref = PatchUtils.readRef(properties, Constants.CUMULATIVE);
  final List<String> patches = PatchUtils.readRefs(properties);
  return new TargetInfoImpl(properties, ref, patches, structure);
}
origin: wildfly/wildfly-core

protected void persist(final String cumulativeID, final List<String> patches, final Properties properties) throws IOException {
  assert cumulativeID != null;
  // Create the parent
  IoUtils.mkdir(structure.getInstallationInfo().getParentFile());
  final List<String> consolidate = new ArrayList<String>();
  consolidate.addAll(patches);
  if (!Constants.BASE.equals(cumulativeID)) {
    consolidate.add(cumulativeID);
  }
  if (structure.getModuleRoot() != null) {
    final File overlays = new File(structure.getModuleRoot(), Constants.OVERLAYS);
    final File refs = new File(overlays, Constants.OVERLAYS);
    PatchUtils.writeRefs(refs, consolidate);
  }
  // Update the properties
  properties.put(Constants.CUMULATIVE, cumulativeID);
  properties.put(Constants.PATCHES, PatchUtils.asString(patches));
  if(version != null) {
    properties.put(Constants.CURRENT_VERSION, version);
  }
  // Write layer.conf
  PatchUtils.writeProperties(structure.getInstallationInfo(), properties);
}
origin: wildfly/wildfly-core

final Properties properties = PatchUtils.loadProperties(identity.getDirectoryStructure().getInstallationInfo());
final List<String> allPatches = PatchUtils.readRefs(properties, Constants.ALL_PATCHES);
origin: wildfly/wildfly-core

@Override
public File[] getTargetModulePath() {
  // We need the updated state for invalidating one-off patches
  // When applying the overlay directory should not exist yet
  final PatchableTarget.TargetInfo updated = mode == Mode.APPLY ? delegate : delegate.getModifiedState();
  return PatchUtils.getModulePath(delegate.getDirectoryStructure(), updated);
}
origin: org.wildfly.core/wildfly-patching

if(cp2Type.equals(ModificationType.REMOVE)) {
  try {
    elementBuilder.addModule(module.getName(), module.getSlot(), PatchUtils.getAbsentModuleContentHash(module));
  } catch (IOException e) {
    throw new PatchingException("Failed to calculate hash for the removed module " + module.getName(), e);
origin: wildfly/wildfly-core

@Override
public void finishPatch(final Patch processedPatch, final RollbackPatch rollbackPatch, final IdentityPatchContext context) throws Exception {
  final File historyDir = structure.getInstalledImage().getPatchHistoryDir(patchId);
  if (!historyDir.exists()) {
    historyDir.mkdirs();
  }
  // Backup the current active patch Info
  final File timestamp = new File(historyDir, Constants.TIMESTAMP);
  PatchUtils.writeRef(timestamp, generateTimestamp());
  // Persist the processed patch, which contains the records of changes
  final File backupPatchXml = new File(historyDir, PatchXml.PATCH_XML);
  IdentityPatchContext.writePatch(processedPatch, backupPatchXml);
  // Persist the rollback.xml in the history directory
  final File rollbackPatchXml = new File(historyDir, Constants.ROLLBACK_XML);
  IdentityPatchContext.writePatch(rollbackPatch, rollbackPatchXml);
  // Backup the configuration
  context.backupConfiguration();
}
org.jboss.as.patching.runnerPatchUtils

Most used methods

  • getAbsentModuleContentHash
  • getModulePath
  • readRefs
  • asString
  • generateTimestamp
  • getAbsentModuleContent
  • getBundlePath
  • getRenamedFileName
  • loadProperties
  • readLine
  • readRef
  • writeLine
  • readRef,
  • writeLine,
  • writeProperties,
  • writeRef,
  • writeRefs

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now