Search in sources :

Example 1 with ZipFile

use of com.sun.enterprise.util.zip.ZipFile in project Payara by payara.

the class JmsRaUtil method upgradeIfNecessary.

/**
 * Obtains the Implementation-Version from the MQ Client libraries
 * that are deployed in the application server and in MQ installation
 * directory.
 */
public void upgradeIfNecessary() {
    String installedMqVersion = null;
    String deployedMqVersion = null;
    try {
        installedMqVersion = getInstalledMqVersion();
        _logger.log(Level.FINE, "installedMQVersion :: " + installedMqVersion);
        deployedMqVersion = getDeployedMqVersion();
        _logger.log(Level.FINE, "deployedMQVersion :: " + deployedMqVersion);
    } catch (Exception e) {
        return;
    }
    String deployed_dir = java.lang.System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY) + File.separator + SYSTEM_APP_DIR + File.separator + ConnectorConstants.DEFAULT_JMS_ADAPTER;
    // explode the MQ resource adapter.
    if (!installedMqVersion.equals(deployedMqVersion)) {
        try {
            _logger.log(Level.INFO, JMSLoggerInfo.JMSRA_UPGRADE_STARTED);
            ZipFile rarFile = new ZipFile(System.getProperty(SystemPropertyConstants.IMQ_LIB_PROPERTY) + File.separator + MQ_RAR, deployed_dir);
            rarFile.explode();
            _logger.log(Level.INFO, JMSLoggerInfo.JMSRA_UPGRADE_COMPLETED);
        } catch (ZipFileException ze) {
            _logger.log(Level.SEVERE, JMSLoggerInfo.JMSRA_UPGRADE_FAILED, new Object[] { ze.getMessage() });
        }
    }
}
Also used : ZipFile(com.sun.enterprise.util.zip.ZipFile) ZipFileException(com.sun.enterprise.util.zip.ZipFileException) ZipFileException(com.sun.enterprise.util.zip.ZipFileException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 2 with ZipFile

use of com.sun.enterprise.util.zip.ZipFile in project Payara by payara.

the class RepositoryManager method createJavaEESEInstallRoot.

/**
 * This method is used to create Java EESE install root
 *
 * @param layout PEFileLayout
 */
public void createJavaEESEInstallRoot(PEFileLayout layout) throws Exception {
    FileUtils.copy(layout.getJavaEESEArchiveSource(), layout.getJavaEESEArchiveDestination());
    ZipFile zf = new ZipFile(layout.getJavaEESEArchiveSource(), layout.getJavaEESEInstallRoot());
    zf.explode();
}
Also used : ZipFile(com.sun.enterprise.util.zip.ZipFile)

Example 3 with ZipFile

use of com.sun.enterprise.util.zip.ZipFile in project Payara by payara.

the class RepositoryManager method createHttpBCInstallRoot.

/**
 * This method is used to create httpsoapbc install root
 *
 * @param layout PEFileLayout
 */
public void createHttpBCInstallRoot(PEFileLayout layout) throws Exception {
    FileUtils.copy(layout.getHttpBcArchiveSource(), layout.getHttpBcArchiveDestination());
    ZipFile zf = new ZipFile(layout.getHttpBcArchiveSource(), layout.getHttpBcInstallRoot());
    zf.explode();
}
Also used : ZipFile(com.sun.enterprise.util.zip.ZipFile)

Example 4 with ZipFile

use of com.sun.enterprise.util.zip.ZipFile in project Payara by payara.

the class ModuleExploder method explodeModule.

public static void explodeModule(Archive source, File directory, boolean preserveManifest) throws IOException, DeploymentException {
    File explodedManifest = null;
    File preservedManifestFromArchive = null;
    FileArchive target = new FileArchive();
    target.create(directory.toURI());
    explodeJar(new File(source.getURI()), directory);
    if (preserveManifest) {
        explodedManifest = new File(directory, java.util.jar.JarFile.MANIFEST_NAME);
        if (explodedManifest.exists()) {
            /* Rename the manifest so it can be restored later. */
            preservedManifestFromArchive = new File(directory, PRESERVED_MANIFEST_NAME);
            if (!explodedManifest.renameTo(preservedManifestFromArchive)) {
                throw new RuntimeException(localStrings.getString("enterprise.deployment.backend.error_saving_manifest", new Object[] { explodedManifest.getAbsolutePath(), preservedManifestFromArchive.getAbsolutePath() }));
            }
        }
    }
    // require access to the manifest file of each .jar file.
    for (Enumeration itr = source.entries(); itr.hasMoreElements(); ) {
        String fileName = (String) itr.nextElement();
        /*
              *Expand the file only if it is a jar and only if it does not lie in WEB-INF/lib.
              */
        if (fileName.toLowerCase(Locale.US).endsWith(".jar") && (!fileName.replace('\\', '/').toUpperCase(Locale.getDefault()).startsWith(WEB_INF_PREFIX))) {
            try {
                File f = new File(directory, fileName);
                ZipFile zip = new ZipFile(f, directory);
                zip.explode();
            } catch (ZipFileException e) {
                IOException ioe = new IOException(e.getMessage());
                ioe.initCause(e);
                throw ioe;
            }
        }
    }
    /*
          *If the archive's manifest was renamed to protect it from being overwritten by manifests from
          *jar files, then rename it back.  Delete an existing manifest file first if needed.
          */
    if (preservedManifestFromArchive != null) {
        if (explodedManifest.exists()) {
            if (!explodedManifest.delete()) {
                throw new RuntimeException(localStrings.getString("enterprise.deployment.backend.error_deleting_manifest", new Object[] { explodedManifest.getAbsolutePath(), preservedManifestFromArchive.getAbsolutePath() }));
            }
        }
        if (!preservedManifestFromArchive.renameTo(explodedManifest)) {
            throw new RuntimeException(localStrings.getString("enterprise.deployment.backend.error_restoring_manifest", new Object[] { preservedManifestFromArchive.getAbsolutePath(), explodedManifest.getAbsolutePath() }));
        }
    }
    source.close();
    target.close();
}
Also used : Enumeration(java.util.Enumeration) ZipFile(com.sun.enterprise.util.zip.ZipFile) ZipFileException(com.sun.enterprise.util.zip.ZipFileException) FileArchive(com.sun.enterprise.deploy.shared.FileArchive) JarFile(java.util.jar.JarFile) ZipFile(com.sun.enterprise.util.zip.ZipFile)

Example 5 with ZipFile

use of com.sun.enterprise.util.zip.ZipFile in project Payara by payara.

the class RestoreManager method restore.

// ////////////////////////////////////////////////////////////////////////
public String restore() throws BackupException {
    try {
        boolean isConfigBackup = isAConfigBackup();
        checkDomainName();
        ZipFile zf = new ZipFile(request.backupFile, tempRestoreDir);
        zf.explode();
        sanityCheckExplodedFiles();
        // the backups directory.
        if (!isConfigBackup)
            copyBackups();
        atomicSwap(request.domainDir, request.domainName, isConfigBackup);
        setPermissions();
        String mesg = readAndDeletePropsFile(isConfigBackup);
        return mesg;
    } catch (BackupException be) {
        throw be;
    } catch (Exception e) {
        throw new BackupException("Restore Error" + e.toString(), e);
    }
}
Also used : ZipFile(com.sun.enterprise.util.zip.ZipFile)

Aggregations

ZipFile (com.sun.enterprise.util.zip.ZipFile)6 ZipFileException (com.sun.enterprise.util.zip.ZipFileException)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)1 Enumeration (java.util.Enumeration)1 JarFile (java.util.jar.JarFile)1