1 23 24 package org.objectweb.cjdbc.controller.backup; 25 26 import java.io.File ; 27 import java.util.HashMap ; 28 import java.util.StringTokenizer ; 29 30 import org.objectweb.cjdbc.common.exceptions.BackupException; 31 import org.objectweb.cjdbc.common.log.Trace; 32 33 39 public abstract class AbstractPostgreSQLBackuper implements Backuper 40 { 41 static Trace logger = Trace.getLogger(AbstractPostgreSQLBackuper.class 43 .getName()); 44 45 protected HashMap optionsMap = new HashMap (); 47 48 protected String optionsString = null; 50 51 56 public AbstractPostgreSQLBackuper() 57 { 58 } 59 60 64 public String getOptions() 65 { 66 return optionsString; 67 } 68 69 73 public void setOptions(String options) 74 { 75 if (options != null) 76 { 77 StringTokenizer strTok = new StringTokenizer (options, ","); 78 String option = null; 79 String name = null; 80 String value = null; 81 82 while (strTok.hasMoreTokens()) 84 { 85 option = strTok.nextToken(); 86 name = option.substring(0, option.indexOf("=")); 87 value = option.substring(option.indexOf("=") + 1, option.length()); 88 optionsMap.put(name, value); 89 } 90 91 optionsString = options; 92 } 93 } 94 95 99 public void deleteDump(String path, String dumpName) throws BackupException 100 { 101 File toRemove = new File (getDumpPhysicalPath(path, dumpName)); 102 if (logger.isDebugEnabled()) 103 logger.debug("Deleting compressed dump " + toRemove); 104 toRemove.delete(); 105 } 106 107 114 protected String getDumpPhysicalPath(String path, String dumpName) 115 { 116 String fullPath = null; 117 118 if (path.endsWith(File.separator)) 119 fullPath = path + dumpName; 120 else 121 fullPath = path + File.separator + dumpName; 122 123 return fullPath; 124 } 125 126 133 protected String getHostFromURL(String url) 134 { 135 return url.substring(18, url.lastIndexOf(":")); 138 } 139 140 147 protected String getPortFromURL(String url) 148 { 149 return url.substring(url.lastIndexOf(":") + 1, url.lastIndexOf("/")); 151 } 152 153 160 protected String getDatabaseNameFromURL(String url) 161 { 162 String dbName = null; 163 164 if (url.indexOf("?") > -1) 166 dbName = url.substring(url.lastIndexOf("/") + 1, url.lastIndexOf("?")); 168 else 169 dbName = url.substring(url.lastIndexOf("/") + 1, url.length()); 170 171 return dbName; 172 } 173 174 178 public void fetchDump(DumpTransferInfo dumpTransferInfo, String path, 179 String dumpName) throws BackupException 180 { 181 } 185 186 189 public DumpTransferInfo setupServer() 190 { 191 return null; 193 } 194 195 198 public BackupManager getBackupManager() 199 { 200 return null; 202 } 204 } 205 | Popular Tags |