1 31 32 package org.opencms.setup.xml; 33 34 import org.opencms.configuration.CmsConfigurationManager; 35 import org.opencms.configuration.CmsSystemConfiguration; 36 import org.opencms.configuration.I_CmsXmlConfiguration; 37 import org.opencms.file.CmsBackupResourceHandler; 38 39 import java.util.Collections ; 40 import java.util.List ; 41 42 import org.dom4j.Document; 43 import org.dom4j.Node; 44 45 54 public class CmsXmlAddBackupResourceHandler extends A_CmsSetupXmlUpdate { 55 56 57 private List m_xpaths; 58 59 62 public String getName() { 63 64 return "Add new backup resource handler"; 65 } 66 67 70 public String getXmlFilename() { 71 72 return CmsSystemConfiguration.DEFAULT_XML_FILE_NAME; 73 } 74 75 78 protected boolean executeUpdate(Document document, String xpath) { 79 80 Node node = document.selectSingleNode(xpath); 81 if (node == null) { 82 if (xpath.equals(getXPathsToUpdate().get(0))) { 83 CmsSetupXmlHelper.setValue( 84 document, 85 xpath + "/@" + I_CmsXmlConfiguration.A_CLASS, 86 CmsBackupResourceHandler.class.getName()); 87 } 88 return true; 89 } 90 return false; 91 } 92 93 96 protected String getCommonPath() { 97 98 return new StringBuffer ("/").append(CmsConfigurationManager.N_ROOT).append("/").append( 100 CmsSystemConfiguration.N_SYSTEM).append("/").append(CmsSystemConfiguration.N_RESOURCEINIT).toString(); 101 } 102 103 106 protected List getXPathsToUpdate() { 107 108 if (m_xpaths == null) { 109 StringBuffer xp = new StringBuffer (256); 111 xp.append("/").append(CmsConfigurationManager.N_ROOT); 112 xp.append("/").append(CmsSystemConfiguration.N_SYSTEM); 113 xp.append("/").append(CmsSystemConfiguration.N_RESOURCEINIT); 114 xp.append("/").append(CmsSystemConfiguration.N_RESOURCEINITHANDLER); 115 xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS); 116 xp.append("='").append(CmsBackupResourceHandler.class.getName()); 117 xp.append("']"); 118 m_xpaths = Collections.singletonList(xp.toString()); 119 } 120 return m_xpaths; 121 } 122 } 123 | Popular Tags |