def _extract_from_archive_if_needed(self, location, key, value): """ Extract the file from the archive, if needed. :param location: the location :param key: the attribute name :param value: the attribute value :return: True if the file/directory was extracted, False otherwise :raise: DeployException: if an error occurs """ _method_name = '_extract_from_archive_if_needed' self.logger.entering(str(location), key, value, class_name=self._class_name, method_name=_method_name) result = False if deployer_utils.is_path_into_archive(value): if self.archive_helper is not None: result = self.__process_archive_entry(location, key, value) else: path = self.alias_helper.get_model_folder_path(location) ex = exception_helper.create_deploy_exception( 'WLSDPLY-09110', key, path, value) self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name) raise ex self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=result) return result
def __get_manifest(self, source_path, from_archive): """ Returns the manifest object for the specified path. The source path may be a jar, or an exploded path. :param source_path: the source path to be checked :param from_archive: if True, use the manifest from the archive, otherwise from the file system :return: the manifest, or None if it is not present :raises: IOException: if there are problems reading an existing manifest """ manifest = None if string_utils.is_empty(source_path): return manifest source_path = self.model_context.replace_token_string(source_path) if from_archive and deployer_utils.is_path_into_archive(source_path): return self.archive_helper.get_manifest(source_path) else: if not os.path.isabs(source_path): # if this was in archive, it has been expanded under domain home. # or it may be a relative file intentionally placed under domain home. source_file = File(File(self.model_context.get_domain_home()), source_path) else: source_file = File(source_path) if source_file.isDirectory(): # read the manifest directly from the file system manifest_file = File(source_file, MANIFEST_NAME) if manifest_file.exists(): stream = None try: stream = FileInputStream(manifest_file) manifest = Manifest(stream) finally: if stream is not None: try: stream.close() except IOException: # nothing to report pass else: # read the manifest from the deployable ear/jar/war on the file system archive = JarFile(source_file.getAbsolutePath()) manifest = archive.getManifest() return manifest