1 23 24 29 30 package com.sun.enterprise.admin.servermgmt; 31 32 import java.util.HashMap ; 33 34 import java.io.File ; 35 36 import com.sun.enterprise.util.SystemPropertyConstants; 37 38 import com.sun.enterprise.util.io.FileUtils; 39 40 83 public class RepositoryConfig extends HashMap { 84 85 public static final String K_INSTALL_ROOT = "install.root"; 86 public static final String K_CONFIG_ROOT = "config.root"; 87 88 private String _repositoryName; 90 91 private String _repositoryRoot; 93 94 private String _instanceName; 96 97 private String _configurationName; 99 100 104 public RepositoryConfig(String repositoryName, String repositoryRoot, String instanceName, 105 String configName) { 106 _instanceName = instanceName; 107 _repositoryName = repositoryName; 108 _repositoryRoot = repositoryRoot; 109 _configurationName = configName; 110 put(K_INSTALL_ROOT, getFilePath(SystemPropertyConstants.INSTALL_ROOT_PROPERTY)); 111 put(K_CONFIG_ROOT, getFilePath(SystemPropertyConstants.CONFIG_ROOT_PROPERTY)); 112 } 113 114 public RepositoryConfig(String repositoryName, String repositoryRoot, String instanceName) { 115 this(repositoryName, repositoryRoot, instanceName, null); 116 } 117 118 public RepositoryConfig(String repositoryName, String repositoryRoot) { 119 this(repositoryName, repositoryRoot, null); 120 } 121 122 128 public RepositoryConfig() { 129 final File instanceRoot = new File (System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY)); 130 final File repositoryDir = instanceRoot.getParentFile(); 131 _instanceName = instanceRoot.getName(); 132 _repositoryName = repositoryDir.getName(); 133 _repositoryRoot = FileUtils.makeForwardSlashes(repositoryDir.getParentFile().getAbsolutePath()); 134 _configurationName = null; 135 put(K_INSTALL_ROOT, getFilePath(SystemPropertyConstants.INSTALL_ROOT_PROPERTY)); 136 put(K_CONFIG_ROOT, getFilePath(SystemPropertyConstants.CONFIG_ROOT_PROPERTY)); 137 } 138 139 public String toString() 140 { 141 return ("repositoryRoot " + _repositoryRoot + " repositoryName " + _repositoryName + 142 " instanceName " + _instanceName + " configurationName " + _configurationName); 143 } 144 145 protected String getFilePath(String propertyName) 146 { 147 File f = new File (System.getProperty(propertyName)); 148 return FileUtils.makeForwardSlashes(f.getAbsolutePath()); 149 } 150 151 public void setConfigurationName(String configurationName) { 152 _configurationName = configurationName; 153 } 154 155 public String getConfigurationName() { 156 return _configurationName; 157 } 158 159 public String getDisplayName() { 160 return getRepositoryName(); 161 } 162 163 public void setInstanceName(String instanceName) { 164 _instanceName = instanceName; 165 } 166 167 public String getInstanceName() { 168 return _instanceName; 169 } 170 171 public String getRepositoryName() { 172 return _repositoryName; 173 } 174 175 protected void setRepositoryRoot(String repositoryRoot) { 176 _repositoryRoot = repositoryRoot; 177 } 178 179 public String getRepositoryRoot() 180 { 181 return _repositoryRoot; 182 } 183 184 public String getInstallRoot() 185 { 186 return (String )get(K_INSTALL_ROOT); 187 } 188 189 public String getConfigRoot() 190 { 191 return (String )get(K_CONFIG_ROOT); 192 } 193 } 194 | Popular Tags |