00001
00027 package org.objectweb.jonas.ant.jonasbase;
00028
00029 import java.util.ArrayList;
00030 import java.util.Iterator;
00031 import java.util.List;
00032 import java.util.Properties;
00033
00034 import org.objectweb.jonas.ant.JOnASBaseTask;
00035
00040 public class WsdlPublish extends JTask implements BaseTaskItf {
00041
00045 private static final String INFO = "[WSDL-Publish] ";
00046
00050 private static final String WSDL_HANDLER_PROPERTY = "jonas.service.ws.wsdlhandlers";
00051
00055 private static final String TOKEN_WSDLHANDLER = WSDL_HANDLER_PROPERTY + " file1";
00056
00060 private List files = new ArrayList();
00061
00065 private List uddis = new ArrayList();
00066
00071 public void addConfiguredFile(File file) {
00072 files.add(file);
00073 }
00074
00079 public void addConfiguredUddi(Uddi uddi) {
00080 uddis.add(uddi);
00081 }
00082
00086 public void execute() {
00087
00088 String fileNameList = "";
00089
00090 java.io.File jonasBaseConfDir = new java.io.File(getDestDir().getPath() + java.io.File.separator + "conf");
00091
00092
00093 for (Iterator it = files.iterator(); it.hasNext();) {
00094 File f = (File) it.next();
00095
00096 String dir = f.getDir();
00097 String encoding = f.getEncoding();
00098 String name = f.getName();
00099
00100
00101 if (fileNameList.length() == 0) {
00102 fileNameList = name;
00103 } else {
00104 fileNameList += "," + name;
00105 }
00106
00107 String fileName = name + ".properties";
00108
00109
00110 Properties props = new Properties();
00111 props.put("jonas.service.wsdl.class", File.FILEWSDLHANDLER_CLASS);
00112 props.put("jonas.service.publish.file.directory", dir);
00113 props.put("jonas.service.publish.file.encoding", encoding);
00114 java.io.File writeFile = new java.io.File(jonasBaseConfDir, fileName);
00115 log(INFO + "Generating a WSDL publish file with name '" + name + "', dir '" + dir + "' and encoding '"
00116 + encoding + "' in file '" + writeFile + "'...");
00117 writePropsToFile(INFO, props, writeFile);
00118 }
00119
00120
00121 for (Iterator it = uddis.iterator(); it.hasNext();) {
00122 Uddi uddi = (Uddi) it.next();
00123
00124 String name = uddi.getName();
00125 String username = uddi.getUserName();
00126 String password = uddi.getPassword();
00127 String orgName = uddi.getOrgName();
00128 String orgDesc = uddi.getOrgDesc();
00129 String orgPersonName = uddi.getOrgPersonName();
00130 String lifecyclemanagerURL = uddi.getLifecyclemanagerURL();
00131 String queryManagerURL = uddi.getQueryManagerURL();
00132
00133
00134 if (fileNameList.length() == 0) {
00135 fileNameList = name;
00136 } else {
00137 fileNameList += "," + name;
00138 }
00139
00140 String fileName = name + ".properties";
00141
00142
00143 Properties props = new Properties();
00144 props.put("jonas.service.wsdl.class", Uddi.REGISTRYWSDLHANDLER_CLASS);
00145 props.put("jonas.service.publish.uddi.username", username);
00146 props.put("jonas.service.publish.uddi.password", password);
00147 props.put("jonas.service.publish.uddi.organization.name", orgName);
00148 props.put("jonas.service.publish.uddi.organization.desc", orgDesc);
00149 props.put("jonas.service.publish.uddi.organization.person_name", orgPersonName);
00150 props.put("javax.xml.registry.lifeCycleManagerURL", lifecyclemanagerURL);
00151 props.put("javax.xml.registry.queryManagerURL", queryManagerURL);
00152 java.io.File writeFile = new java.io.File(jonasBaseConfDir, fileName);
00153 log(INFO + "Generating a WSDL publish UDDI with name '" + name + "' in file '" + writeFile + "'...");
00154 writePropsToFile(INFO, props, writeFile);
00155 }
00156
00157
00158 JReplace propertyReplace = new JReplace();
00159 propertyReplace.setProject(getProject());
00160 propertyReplace.setConfigurationFile(JOnASBaseTask.JONAS_CONF_FILE);
00161 propertyReplace.setDestDir(new java.io.File(getDestDir().getPath()));
00162 propertyReplace.setToken(TOKEN_WSDLHANDLER);
00163 propertyReplace.setValue(WSDL_HANDLER_PROPERTY + SEPARATORS + fileNameList);
00164 log(INFO + "Adding WSDL handlers '" + fileNameList + "' in " + JOnASBaseTask.JONAS_CONF_FILE + " file.");
00165 propertyReplace.execute();
00166
00167 }
00168
00173 public static class File {
00174
00178 private String dir = null;
00179
00183 public static final String FILEWSDLHANDLER_CLASS = "org.objectweb.jonas.ws.handler.FileWSDLHandler";
00184
00188 private static final String DEFAULT_ENCODING = "UTF-8";
00189
00194 private String encoding = DEFAULT_ENCODING;
00195
00199 private String name = null;
00200
00205 public String getDir() {
00206 return dir;
00207 }
00208
00213 public void setDir(String dir) {
00214 this.dir = dir;
00215 }
00216
00221 public String getEncoding() {
00222 return encoding;
00223 }
00224
00229 public void setEncoding(String encoding) {
00230 this.encoding = encoding;
00231 }
00232
00237 public String getName() {
00238 return name;
00239 }
00240
00245 public void setName(String name) {
00246 this.name = name;
00247 }
00248 }
00249
00254 public static class Uddi {
00255
00259 public static final String REGISTRYWSDLHANDLER_CLASS = "org.objectweb.jonas.ws.handler.RegistryWSDLHandler";
00260
00264 private String name = null;
00265
00269 private String userName = null;
00270
00274 private String password = null;
00275
00279 private String orgName = null;
00280
00284 private String orgDesc = null;
00285
00289 private String orgPersonName = null;
00290
00294 private String lifecyclemanagerURL = null;
00295
00299 private String queryManagerURL = null;
00300
00305 public String getName() {
00306 return name;
00307 }
00308
00313 public void setName(String name) {
00314 this.name = name;
00315 }
00316
00320 public String getLifecyclemanagerURL() {
00321 return lifecyclemanagerURL;
00322 }
00323
00327 public void setLifecyclemanagerURL(String lifecyclemanagerURL) {
00328 this.lifecyclemanagerURL = lifecyclemanagerURL;
00329 }
00330
00334 public String getOrgDesc() {
00335 return orgDesc;
00336 }
00337
00341 public void setOrgDesc(String orgDesc) {
00342 this.orgDesc = orgDesc;
00343 }
00344
00348 public String getOrgName() {
00349 return orgName;
00350 }
00351
00355 public void setOrgName(String orgName) {
00356 this.orgName = orgName;
00357 }
00358
00362 public String getOrgPersonName() {
00363 return orgPersonName;
00364 }
00365
00369 public void setOrgPersonName(String orgPersonName) {
00370 this.orgPersonName = orgPersonName;
00371 }
00372
00376 public String getPassword() {
00377 return password;
00378 }
00379
00383 public void setPassword(String password) {
00384 this.password = password;
00385 }
00386
00390 public String getQueryManagerURL() {
00391 return queryManagerURL;
00392 }
00393
00397 public void setQueryManagerURL(String queryManagerURL) {
00398 this.queryManagerURL = queryManagerURL;
00399 }
00400
00404 public String getUserName() {
00405 return userName;
00406 }
00407
00411 public void setUserName(String userName) {
00412 this.userName = userName;
00413 }
00414 }
00415
00416 }