📄 jahiaearfilehandler.java
字号:
//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//////// JahiaEarFileHandler//// NK 13.01.2001////package org.jahia.data.webapps;import java.io.*;import java.util.*;import java.util.jar.*;import java.util.zip.*;//import com.sun.xml.tree.*;import org.w3c.dom.*;//import org.xml.sax.*;import org.jahia.exceptions.*;import org.jahia.utils.zip.*; // JahiaarHandlerimport org.jahia.utils.*; // JahiaCmdExecimport org.jahia.utils.xml.*; // XMLParserimport org.jahia.registries.ServicesRegistry;/** * This class is responsible for loading data from a .Ear File * The Information are loaded from the META-INF/application.xml file : * * ----------------------------------------------------------------- * IMPORTANT !!!!! Must call the method closeArchiveFile() * to be able to delete the file later !!! * ----------------------------------------------------------------- * * @author Khue ng * @version 1.0 * */public class JahiaEarFileHandler { /** The web.xml file **/ private static final String APPLICATION_XML_FILE = "META-INF/application.xml"; /** The Full path to the Ear File **/ private String m_FilePath; /** The Archive File **/ private JahiaArchiveFileHandler m_ArchFile; /** The List of Web Compomnents Definition **/ private Vector m_WebComponents = new Vector(); /** The Application_Xml to store data extracted from application.xml file **/ private Application_Xml m_AppXmlDoc ; /** * Constructor is initialized with the Ear File full path * */ public JahiaEarFileHandler (String filePath) throws JahiaException { m_FilePath = filePath; File f = new File(filePath); try { m_ArchFile = new JahiaArchiveFileHandler( f.getAbsolutePath() ); } catch (IOException e ) { String errMsg = "Failed creating an Archive File Handler " ; JahiaConsole.println("JahiaEarFileHandler::Constructor", errMsg + "\n" + e.toString()); throw new JahiaException ("JahiaEarFileHandler", errMsg , JahiaException.SERVICE_ERROR, JahiaException.ERROR); } try { buildWebComponents(); } catch ( JahiaException je ) { if ( m_ArchFile != null ){ m_ArchFile.closeArchiveFile(); } JahiaConsole.println("JahiaEarFileHandler:: Constructor", "error building the WebApssWarPackage" + je.toString()); throw new JahiaException ("JahiaEarFileHandler", "error building the JahiaWebAppsWar Package" , JahiaException.SERVICE_ERROR, JahiaException.ERROR); } } /** * Extract data from the application.xml file and build the list * of WebComponents Definition * */ protected void buildWebComponents() throws JahiaException { // extract data from the application.xml file try { File tmpFile = m_ArchFile.extractFile(APPLICATION_XML_FILE); //System.out.println(" tmpxmlfile is " + tmpFile.getAbsolutePath() ); m_AppXmlDoc = new Application_Xml(tmpFile.getAbsolutePath()); m_AppXmlDoc.extractDocumentData(); m_WebComponents = m_AppXmlDoc.getWebComponents(); tmpFile.deleteOnExit(); tmpFile.delete(); } catch (IOException ioe){ String errMsg = "Failed extracting application.xml file data " ; JahiaConsole.println("JahiaEarFileHandler:: buildWebComponents", errMsg + "\n" + ioe.toString()); throw new JahiaException ("JahiaEarFileHandler", errMsg , JahiaException.SERVICE_ERROR, JahiaException.ERROR); } } /** * Returns the WebComponents list * * @return (Vector) the list of Web Component Definitions */ public Vector getWebComponents(){ return m_WebComponents; } /** * Unzip the contents of the jar file in it's current folder * */ public void unzip() throws JahiaException { // Unzip the file m_ArchFile.unzip(); } /** * Unzip the contents of the jar file in a gived folder * * @param (String) path , the path where to extract file */ public void unzip(String path) throws JahiaException { // Unzip the file m_ArchFile.unzip(path); } /** * Unzip an entry in a gived folder * * @param (String) entryName , the name of the entry * @param (String) path , the path where to extract file */ public void extractEntry( String entryName, String path) throws JahiaException { // Unzip the entry m_ArchFile.extractEntry(entryName, path); } /** * Close the Jar file * */ public void closeArchiveFile(){ if ( m_ArchFile != null ) { m_ArchFile.closeArchiveFile(); } }} // End Class JahiaEarFileHandler
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -