Author: ruwan Date: Wed Jan 26 09:20:00 2011 New Revision: 1063651 URL: http://svn.apache.org/viewvc?rev=1063651&view=rev Log: Applying the patch from Harshana on the issue AXIS2-4920 - part2
Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/JavaWSDLOutputLocationPage.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OptionsPage.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OutputPage.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/WSDLJavaAdvanceDialog.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/ClassFileReader.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/NamespaceFinder.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java Wed Jan 26 09:20:00 2011 @@ -33,6 +33,7 @@ import java.net.URL; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; public class WSDL2JavaGenerator { @@ -147,15 +148,14 @@ public class WSDL2JavaGenerator { } if (advanceOptions != null) { - for (Iterator iterator = advanceOptions.keySet().iterator(); iterator - .hasNext();) { - String type = (String) iterator.next(); - String[] parameters; - if (advanceOptions.get(type) == null) - parameters = new String[0]; - else - parameters = (String[]) advanceOptions.get(type); - optionMap.put(type, new CommandLineOption(type, parameters)); + for (Iterator iterator = advanceOptions.entrySet().iterator(); iterator.hasNext();) { + Entry entry=(Entry) iterator.next(); + String key=(String) entry.getKey(); + String[] value=(String[]) entry.getValue(); + if (value == null) { + value = new String[0]; + } + optionMap.put(key, new CommandLineOption(key, value)); } } return optionMap; Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java Wed Jan 26 09:20:00 2011 @@ -38,6 +38,9 @@ import org.apache.axis2.tool.core.JarFil import org.apache.axis2.tool.core.SrcCompiler; import org.apache.axis2.wsdl.codegen.CodeGenConfiguration; import org.apache.axis2.wsdl.codegen.CodeGenerationEngine; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.impl.Log4JLogger; import org.apache.ws.java2wsdl.Java2WSDLCodegenEngine; import org.apache.ws.java2wsdl.utils.Java2WSDLCommandLineOption; import org.eclipse.core.resources.IWorkspace; @@ -88,6 +91,7 @@ public class CodeGenWizard extends Wizar private int selectedCodegenOptionType = SettingsConstants.CODEGEN_DEFAULT_TYPE;//TODO change this + private static Log logger=LogFactory.getLog(CodeGenWizard.class); @@ -201,8 +205,9 @@ public class CodeGenWizard extends Wizar { protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException{ - if (monitor == null) + if (monitor == null){ monitor = new NullProgressMonitor(); + } /* * "3" is the total amount of steps, see below monitor.worked(amount) @@ -376,8 +381,9 @@ public class CodeGenWizard extends Wizar WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) { - if (monitor == null) + if (monitor == null){ monitor = new NullProgressMonitor(); + } /* * "2" is the total amount of steps, see below @@ -523,10 +529,7 @@ public class CodeGenWizard extends Wizar private void addLibsToProjectLib(String libDirectory, String outputLocation){ String newOutputLocation = outputLocation+File.separator+UIConstants.LIB; //Create a lib directory; all ancestor directories must exist - boolean success = (new File(newOutputLocation)).mkdir(); - if (!success) { - // Directory creation failed - } + new File(newOutputLocation).mkdir(); try { copyDirectory(new File(libDirectory),new File(newOutputLocation)); } catch (IOException e) { @@ -555,17 +558,31 @@ public class CodeGenWizard extends Wizar // Copies src file to dst file. // If the dst file does not exist, it is created private void copyFile(File src, File dst) throws IOException { - InputStream in = new FileInputStream(src); - OutputStream out = new FileOutputStream(dst); - - // Transfer bytes from in to out - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - in.close(); - out.close(); + InputStream in = null; + OutputStream out = null; + try { + in = new FileInputStream(src); + out = new FileOutputStream(dst); + + // Transfer bytes from in to out + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); + } catch (Exception e) { + logger.error("Error while copying the files",e); + throw new IOException(); + }finally{ + try { + in.close(); + out.close(); + } catch (Exception e) { + logger.debug("Failed to close the streams",e); + } + } } // Deletes all files and subdirectories under dir. Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/JavaWSDLOutputLocationPage.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/JavaWSDLOutputLocationPage.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/JavaWSDLOutputLocationPage.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/JavaWSDLOutputLocationPage.java Wed Jan 26 09:20:00 2011 @@ -262,14 +262,13 @@ public class JavaWSDLOutputLocationPage // Fixing issue AXIS2-4008 by retrieving the project // path instead of appending it to the workspace root. IProject project = null; - String otherSegments = EMPTY_STRING; + StringBuilder builder=new StringBuilder(); if (path.segmentCount() > 1) { // User has selected a folder inside a project project = root.getProject(path.segment(ECLIPSE_PROJECT_NAME_SEGMENT_INDEX)); - for (int i = ECLIPSE_PROJECT_NAME_SEGMENT_INDEX + 1; i < path.segments().length; i++) { - otherSegments += File.separator + path.segment(i); + builder.append(File.separator).append(path.segment(i)); } } else { project = root.getProject(path.toOSString()); @@ -277,7 +276,7 @@ public class JavaWSDLOutputLocationPage if (project != null) { outputFolderTextBox.setText(project.getLocation() - .toOSString() + otherSegments); + .toOSString() + builder.toString()); } else { // append to the workspace path if the project is // null Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OptionsPage.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OptionsPage.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OptionsPage.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OptionsPage.java Wed Jan 26 09:20:00 2011 @@ -60,6 +60,10 @@ import java.util.Map; */ public class OptionsPage extends AbstractWizardPage implements UIConstants { + private static final String EQUALS_SIGN = "="; + + private static final String EMPTY_STRING = ""; + /** * Selection list for target languages */ @@ -138,8 +142,8 @@ public class OptionsPage extends Abstrac private java.util.List serviceQNameList = null; - private final int EDITABLECOLUMN = 1; - private String defaultPackageName = null; +// private final int EDITABLECOLUMN = 1; +// private String defaultPackageName = null; private Combo codegenOptionSelectionComboBox; @@ -339,9 +343,9 @@ public class OptionsPage extends Abstrac packageText.setLayoutData(gd); String packageName; String storedPackageName = settings.get(PREF_PACKAGE_NAME); - this.defaultPackageName = storedPackageName; - if (storedPackageName.equals("")) { - packageName = URLProcessor.makePackageName(""); +// this.defaultPackageName = storedPackageName; + if (storedPackageName.equals(EMPTY_STRING)) { + packageName = URLProcessor.makePackageName(EMPTY_STRING); } else { packageName = storedPackageName; } @@ -652,8 +656,9 @@ public class OptionsPage extends Abstrac visible = true; } } - if (!visible) + if (!visible){ return; + } index++; } } @@ -750,11 +755,12 @@ public class OptionsPage extends Abstrac * since the WSDLselection page may call this */ public void populateParamsFromWSDL() { - if (reader == null) + if (reader == null){ reader = new WSDLPropertyReader(); + } try { String lname = getCodegenWizard().getWSDLname(); - if (!"".equals(lname.trim())) { + if (!EMPTY_STRING.equals(lname.trim())) { reader.readWSDL(lname); @@ -780,8 +786,12 @@ public class OptionsPage extends Abstrac } else { // service name list being empty means we are switching to // the interface mode - if (serviceNameCombo!=null) serviceNameCombo.removeAll(); - if (portNameCombo!=null) portNameCombo.removeAll(); + if (serviceNameCombo != null) { + serviceNameCombo.removeAll(); + } + if (portNameCombo != null) { + portNameCombo.removeAll(); + } // disable the combo's setComboBoxEnable(false); //this is not an error @@ -1056,7 +1066,7 @@ public class OptionsPage extends Abstrac * @return a string containing the package name to use for code generation */ public String getPackageName() { - if ("".equals(packageText.getText().trim())){ + if (EMPTY_STRING.equals(packageText.getText().trim())){ //we do not allow the packaging to be empty //if the user sets it to empty we set it to //the default @@ -1079,10 +1089,11 @@ public class OptionsPage extends Abstrac * @return true if "Generate XML configuration file" is checked */ public boolean isServerXML() { - if (this.serverXMLCheckBoxButton.isEnabled()) + if (this.serverXMLCheckBoxButton.isEnabled()){ return this.serverXMLCheckBoxButton.getSelection(); - else + }else{ return false; + } } /** @@ -1111,7 +1122,7 @@ public class OptionsPage extends Abstrac if (selectionIndex != -1) { String text = this.portNameCombo.getItem(selectionIndex); - if (text == null || text.trim().equals("")) { + if (text == null || text.trim().equals(EMPTY_STRING)) { return null; } return text; @@ -1130,7 +1141,7 @@ public class OptionsPage extends Abstrac if (selectionIndex != -1) { String text = this.serviceNameCombo.getItem(selectionIndex); - if (text == null || text.trim().equals("")) { + if (text == null || text.trim().equals(EMPTY_STRING)) { return null; } return text; @@ -1170,19 +1181,21 @@ public class OptionsPage extends Abstrac * @return */ public String getNs2PkgMapping(){ - String returnList=""; +// String returnList=EMPTY_STRING; + StringBuilder builder=new StringBuilder(); TableItem[] items = namespace2packageTable.getItems(); String packageValue; for (int i=0;i<items.length;i++){ packageValue = items[i].getText(1); - if (packageValue!=null && !"".equals(packageValue)){ - returnList = returnList + - ("".equals(returnList)?"":",") + - items[i].getText(0)+ "=" + packageValue; + if (packageValue!=null && !EMPTY_STRING.equals(packageValue)){ +// returnList = returnList + +// (EMPTY_STRING.equals(returnList)?EMPTY_STRING:",") + +// items[i].getText(0)+ EQUALS_SIGN + packageValue; +// + builder.append(EMPTY_STRING.equals(builder.toString())?EMPTY_STRING:",").append(items[i].getText(0)).append(EQUALS_SIGN).append(packageValue); } - } - return "".equals(returnList)?null:returnList; + return EMPTY_STRING.equals(builder.toString())?null:builder.toString(); } @@ -1249,7 +1262,7 @@ public class OptionsPage extends Abstrac // This method is add as a tempory fix for the Axis2-1368 // TODO fix this permanantly. String text = this.packageText.getText(); - if ((text == null) || (text.trim().equals(""))|| (text.endsWith(".")) || (text.startsWith("."))) { + if ((text == null) || (text.trim().equals(EMPTY_STRING))|| (text.endsWith(".")) || (text.startsWith("."))) { updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin .getResourceString("page2.pachage.error.nolocation")); return; @@ -1274,9 +1287,10 @@ public class OptionsPage extends Abstrac } public HashMap getAdvanceOptions(){ - if (advanceOptionsButton.getEnabled()) + if (advanceOptionsButton.getEnabled()){ return advanceOptions; - else + }else{ return getInitialisedAdvanceOptions(); + } } } Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OutputPage.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OutputPage.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OutputPage.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/OutputPage.java Wed Jan 26 09:20:00 2011 @@ -100,9 +100,9 @@ public class OutputPage extends Abstract * Creates some initial values for the settings. */ protected void initializeDefaultSettings() { - settings.put(PREF_OUTPUT_LOCATION, ""); - settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, ""); - settings.put(PREF_JAR_FILE_NAME, ""); + settings.put(PREF_OUTPUT_LOCATION, EMPTY_STRING); + settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, EMPTY_STRING); + settings.put(PREF_JAR_FILE_NAME, EMPTY_STRING); settings.put(PREF_CHECK_WORKSPACE, false); settings.put(PREF_CHECK_FILE_SYSTEM, true); settings.put(PREF_CHECK_AXIS_LIB_COPY, false); @@ -175,8 +175,8 @@ public class OutputPage extends Abstract .setText(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin .getResourceString("page3.output.caption")); - settings.put(PREF_OUTPUT_LOCATION, ""); - settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, ""); + settings.put(PREF_OUTPUT_LOCATION, EMPTY_STRING); + settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, EMPTY_STRING); outputLocation = new Text(container, SWT.BORDER); outputLocation.setText(settings.get(PREF_OUTPUT_LOCATION)); outputLocation.setLayoutData(gd); @@ -217,7 +217,7 @@ public class OutputPage extends Abstract gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan=3; Label fillLabel = new Label(container, SWT.NULL); - fillLabel.setText(""); + fillLabel.setText(EMPTY_STRING); //filling label gd = new GridData(GridData.FILL_HORIZONTAL); @@ -252,7 +252,7 @@ public class OutputPage extends Abstract axisHomeLocation = new Text(container, SWT.BORDER); axisHomeLocation.setLayoutData(gd); - settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, ""); + settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, EMPTY_STRING); axisHomeLocation.setText(settings.get(PREF_AXIS_HOME_OUTPUT_LOCATION)); axisHomeLocation.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { @@ -283,7 +283,7 @@ public class OutputPage extends Abstract gd.horizontalSpan = 2; gd = new GridData(GridData.FILL_HORIZONTAL); axisLoadLibResultsLabel = new Label(container, SWT.NULL); - axisLoadLibResultsLabel .setText(""); + axisLoadLibResultsLabel .setText(EMPTY_STRING); axisLoadLibResultsLabel.setLayoutData(gd); //filling label @@ -431,7 +431,7 @@ public class OutputPage extends Abstract */ private void handleModifyEvent() { String text = this.outputLocation.getText(); - if ((text == null) || (text.trim().equals(""))) { + if ((text == null) || (text.trim().equals(EMPTY_STRING))) { updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin .getResourceString("page3.error.nolocation")); return; @@ -442,7 +442,7 @@ public class OutputPage extends Abstract private void handleAxisHomeModifyEvent() { String text = this.axisHomeLocation.getText(); - if ((text == null) || (text.trim().equals(""))) { + if ((text == null) || (text.trim().equals(EMPTY_STRING))) { updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin .getResourceString("page3.error.nolocation")); return; @@ -496,9 +496,9 @@ public class OutputPage extends Abstract settings.put(PREF_CHECK_JAR_CREATION, true); }else{ settings.put(PREF_CHECK_JAR_CREATION, false); - this.jarFileNameText.setText(""); + this.jarFileNameText.setText(EMPTY_STRING); } - if(jarFileNameLabel.equals("")){ + if(EMPTY_STRING.equals(jarFileNameLabel.getText())){ updateStatus("Please enter a valid name to the jar file"); } } @@ -510,11 +510,11 @@ public class OutputPage extends Abstract this.jarCreationButton.setSelection(false); this.jarCreationButton.setEnabled(false); this.axisHomeLabel.setEnabled(false); - this.axisLoadLibResultsLabel.setText(""); + this.axisLoadLibResultsLabel.setText(EMPTY_STRING); this.axisLoadLibResultsLabel.setEnabled(false); this.axisLoadLibsButton.setEnabled(false); this.jarFileNameLabel.setEnabled(false); - this.jarFileNameText.setText(""); + this.jarFileNameText.setText(EMPTY_STRING); this.jarFileNameText.setEnabled(false); settings.put(PREF_CHECK_JAR_CREATION, false); jarFileCopyOption = false; @@ -531,7 +531,7 @@ public class OutputPage extends Abstract this.axisLoadLibsButton.setEnabled(true); this.jarFileNameLabel.setEnabled(true); this.jarFileNameText.setEnabled(true); - if (axisLoadLibResultsLabel.getText().equals("")){ + if (axisLoadLibResultsLabel.getText().equals(EMPTY_STRING)){ updateStatus("Please enter a valid path to the Axis2 libs and then try to load the libraries using the check libs button"); } axisLoadLibResultsLabel.setText(CodegenWizardPlugin @@ -551,11 +551,11 @@ public class OutputPage extends Abstract } private void handleLoadLibsBrowse() { - if(axisHomeLocation.getText().equals("")){ + if(axisHomeLocation.getText().equals(EMPTY_STRING)){ axisLoadLibResultsLabel.setText(CodegenWizardPlugin .getResourceString("page3.loadlib.fail.caption")); jarFileCopyOption=false; - if (axisLoadLibResultsLabel.getText().equals("")){ + if (axisLoadLibResultsLabel.getText().equals(EMPTY_STRING)){ updateStatus("Please enter a valid path to the Axis2 libs and then try to load the libraries using the check libs button"); } }else{ @@ -571,8 +571,7 @@ public class OutputPage extends Abstract .getResourceString("page3.loadlib.success.caption")); if(axis_libs_directory.isDirectory()){ axis2LibsLocation=axis_std_lib_directory; - } - else if(axis_target_libs_directory.isDirectory()){ + }else if(axis_target_libs_directory.isDirectory()){ axis2LibsLocation=axis_target_lib; } jarFileCopyOption =true; @@ -629,14 +628,13 @@ public class OutputPage extends Abstract if (root.exists(path)) { //Fixing issue AXIS2-4008 by retrieving the project path instead of appending it to the workspace root. IProject project = null; - String otherSegments = EMPTY_STRING; + StringBuilder builder=new StringBuilder(); if (path.segmentCount() > 1) { // User has selected a folder inside a project project = root.getProject(path.segment(ECLIPSE_PROJECT_NAME_SEGMENT_INDEX)); - for (int i = ECLIPSE_PROJECT_NAME_SEGMENT_INDEX + 1; i < path.segments().length; i++) { - otherSegments += File.separator + path.segment(i); + builder.append(File.separator).append(path.segment(i)); } } else { project = root.getProject(path.toOSString()); @@ -644,7 +642,7 @@ public class OutputPage extends Abstract if (project != null) { outputLocation.setText(project.getLocation() - .toOSString() + otherSegments); + .toOSString() + builder.toString()); } else { // append to the workspace path if the project is // null Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/WSDLJavaAdvanceDialog.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/WSDLJavaAdvanceDialog.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/WSDLJavaAdvanceDialog.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/ui/WSDLJavaAdvanceDialog.java Wed Jan 26 09:20:00 2011 @@ -28,7 +28,7 @@ import org.eclipse.swt.widgets.Text; public class WSDLJavaAdvanceDialog extends Dialog { private Button tmpCheckBox; - private Text tmpTextBox; +// private Text tmpTextBox; private HashMap advanceOptions; private boolean isEditAdvanceOptions=false; private Combo wsdlVersionCombo; @@ -40,10 +40,11 @@ public class WSDLJavaAdvanceDialog exten protected WSDLJavaAdvanceDialog(Shell shell, HashMap advanceOptions) { super(shell); isEditAdvanceOptions=(advanceOptions!=null); - if (isEditAdvanceOptions) + if (isEditAdvanceOptions){ this.advanceOptions=(HashMap) advanceOptions.clone(); - else + }else{ this.advanceOptions=new HashMap(); + } } private Button addCheckBox(Composite container, @@ -53,8 +54,9 @@ public class WSDLJavaAdvanceDialog exten //tmpCheckBox = new Button(container, SWT.CHECK); tmpCheckBox.setLayoutData(gd); tmpCheckBox.setText(caption); - if (isEditAdvanceOptions) + if (isEditAdvanceOptions){ tmpCheckBox.setSelection(advanceOptions.containsKey(parameterType)); + } tmpCheckBox.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { setCheckBoxState(parameterType, tmpCheckBox.getSelection()); @@ -71,14 +73,17 @@ public class WSDLJavaAdvanceDialog exten lblCaption.setLayoutData(gd); lblCaption.setText(caption); gd = new GridData(GridData.FILL_HORIZONTAL); - if (isBrowseFolder) + if (isBrowseFolder){ gd.horizontalSpan = 1; - else + }else{ gd.horizontalSpan = 2; + } tmpTextBox.setLayoutData(gd); - if (isEditAdvanceOptions) - if (advanceOptions.containsKey(parameterType)) + if (isEditAdvanceOptions){ + if (advanceOptions.containsKey(parameterType)){ tmpTextBox.setText(((String[])advanceOptions.get(parameterType))[0]); + } + } tmpTextBox.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { setTextBoxValue(parameterType, tmpTextBox.getText()); @@ -185,8 +190,9 @@ public class WSDLJavaAdvanceDialog exten wsdlVersionCombo.setLayoutData(gd); fillWSDLVersionCombo(); String key=CommandLineOptionConstants.WSDL2JavaConstants.WSDL_VERSION_OPTION; - if ((isEditAdvanceOptions) && (advanceOptions.containsKey(key))) + if ((isEditAdvanceOptions) && (advanceOptions.containsKey(key))){ wsdlVersionCombo.select(wsdlVersionCombo.indexOf(((String[])advanceOptions.get(key))[0])); + } wsdlVersionCombo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { @@ -243,7 +249,9 @@ public class WSDLJavaAdvanceDialog exten gd.heightHint = 80; packageNameList.setLayoutData(gd); packageNameList.setVisible(false); - if (isEditAdvanceOptions) updateExcludePackageList(); + if (isEditAdvanceOptions){ + updateExcludePackageList(); + } packageNameList.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { handlePackageNameListClick(); @@ -293,19 +301,22 @@ public class WSDLJavaAdvanceDialog exten String toRemove=packageNameList.getItem(selectedIndex).getText(); for (String s : packageList) { if (!s.equalsIgnoreCase(toRemove)){ - if (newList.equalsIgnoreCase("")) + if (newList.equalsIgnoreCase("")){ newList=s; - else + }else{ newList=newList+","+s; + } } } - if (newList.equalsIgnoreCase("")) + if (newList.equalsIgnoreCase("")){ advanceOptions.remove(type); - else + }else{ advanceOptions.put(type, new String[]{newList}); + } packageNameList.remove(selectedIndex); - if (selectedIndex>=packageNameList.getItemCount()) + if (selectedIndex>=packageNameList.getItemCount()){ selectedIndex--; + } packageNameList.select(selectedIndex); } packageNameList.redraw(); @@ -359,17 +370,19 @@ public class WSDLJavaAdvanceDialog exten wsdlVersionCombo.add("2.0"); } private void setCheckBoxState(String type,boolean state){ - if (state) + if (state){ advanceOptions.put(type, null); - else + }else{ advanceOptions.remove(type); + } } private void setTextBoxValue(String type,String value){ - if (value.equalsIgnoreCase("")) + if (value.equalsIgnoreCase("")){ advanceOptions.remove(type); - else + }else{ advanceOptions.put(type, new String[]{value}); + } } public HashMap getAdvanceOptions(){ Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/ClassFileReader.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/ClassFileReader.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/ClassFileReader.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/ClassFileReader.java Wed Jan 26 09:20:00 2011 @@ -23,7 +23,9 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.security.AccessController; import java.util.List; +import java.security.PrivilegedAction; /** * A utility class for reading/loading classes and @@ -45,7 +47,7 @@ public class ClassFileReader { ClassLoader classLoader; if (classPathEntries.length > 0) { - URL[] urls = new URL[classPathEntries.length]; + final URL[] urls = new URL[classPathEntries.length]; try { for (int i = 0; i < classPathEntries.length; i++) { @@ -64,7 +66,11 @@ public class ClassFileReader { return false; } - classLoader = new URLClassLoader(urls); + classLoader = AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() { + public URLClassLoader run() { + return new URLClassLoader(urls); + } + }); } else { classLoader = Thread.currentThread().getContextClassLoader(); Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/NamespaceFinder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/NamespaceFinder.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/NamespaceFinder.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/eclipse/util/NamespaceFinder.java Wed Jan 26 09:20:00 2011 @@ -21,6 +21,7 @@ package org.apache.axis2.tool.codegen.ec public class NamespaceFinder { + private static final String EMPTY_STRING = ""; private static String NS_PREFIX = "http://"; private static String SCHEMA_NS_DEFAULT_PREFIX = "xsd"; private static String NS_DEFAULT_PREFIX = "ns"; @@ -30,12 +31,12 @@ public class NamespaceFinder { //tokenize the className String[] classNameParts = fullyQualifiedClassName.split("\\."); //add the strings in reverse order to make the namespace - String nsUri = ""; + StringBuilder builder=new StringBuilder(); for(int i=classNameParts.length-2;i>=0;i--){ - nsUri = nsUri + classNameParts[i] + (i==0?"":"."); + builder.append(classNameParts[i]).append(i==0?EMPTY_STRING:"."); } - return NS_PREFIX + nsUri; + return NS_PREFIX + builder.toString(); } Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/ClassFileHandler.java Wed Jan 26 09:20:00 2011 @@ -24,7 +24,9 @@ import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.security.AccessController; import java.util.ArrayList; +import java.security.PrivilegedAction; public class ClassFileHandler { @@ -41,10 +43,15 @@ public class ClassFileHandler { public ArrayList getMethodNamesFromClass(String classFileName,String location) throws IOException, ClassNotFoundException{ ArrayList returnList = new ArrayList(); File fileEndpoint = new File(location); - if (!fileEndpoint.exists()) + if (!fileEndpoint.exists()){ throw new IOException("the location is invalid"); - URL[] urlList = {fileEndpoint.toURL()}; - URLClassLoader clazzLoader = new URLClassLoader(urlList); + } + final URL[] urlList = {fileEndpoint.toURL()}; + URLClassLoader clazzLoader = AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() { + public URLClassLoader run() { + return new URLClassLoader(urlList); + } + }); Class clazz = clazzLoader.loadClass(classFileName); Method[] methods = clazz.getDeclaredMethods(); Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/FileCopier.java Wed Jan 26 09:20:00 2011 @@ -35,9 +35,9 @@ public class FileCopier extends Copy{ } public void copyFiles(File sourceFile,File destinationDirectory,String filter){ - if (sourceFile.isFile()) + if (sourceFile.isFile()){ this.setFile(sourceFile); - else { + }else { FileSet fileset = new FileSet(); fileset.setDir(sourceFile); if (filter!=null){ Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/JarFileWriter.java Wed Jan 26 09:20:00 2011 @@ -41,8 +41,9 @@ public class JarFileWriter extends Jar{ if (!outputFolder.exists()){ outputFolder.mkdir(); //create the output path }else{ - if (!outputFolder.isDirectory()) + if (!outputFolder.isDirectory()){ return; + } } File targetFile = new File(outputFolder,outputFileName); Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/core/SrcCompiler.java Wed Jan 26 09:20:00 2011 @@ -45,8 +45,7 @@ public class SrcCompiler extends Javac { this.setDestdir(destDir); this.setIncludes("**/*.java, *.java"); File lib = new File(compilableSrcLocation+ File.separator + "lib"); - File files [] = new File[lib.listFiles().length]; - files = lib.listFiles(); + File files [] = lib.listFiles(); Path classpath = new Path(project); for (int count =0;count<files.length;count++){ Modified: axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java?rev=1063651&r1=1063650&r2=1063651&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java (original) +++ axis/axis2/java/core/trunk/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/util/Constants.java Wed Jan 26 09:20:00 2011 @@ -20,7 +20,7 @@ package org.apache.axis2.tool.util; public class Constants { - public class UIConstants{ + public static class UIConstants{ public static final int LABEL_WIDTH=100; public static final int RADIO_BUTTON_WIDTH=200; public static final int TEXT_BOX_WIDTH=250;