|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Balan Subramanian (bsubram@us.ibm.com) |
| 10 |
* IBM Corporation - initial API and implementation |
| 11 |
*******************************************************************************/ |
| 12 |
|
| 13 |
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional; |
| 14 |
|
| 15 |
import java.io.File; |
| 16 |
import java.io.FileFilter; |
| 17 |
import java.util.LinkedList; |
| 18 |
import java.util.List; |
| 19 |
|
| 20 |
import org.eclipse.osgi.util.NLS; |
| 21 |
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages; |
| 22 |
|
| 23 |
/** |
| 24 |
* This class verifies the Axis2 Soap Library dependency. |
| 25 |
*/ |
| 26 |
|
| 27 |
public class Axis2ServerDependency implements ISoapServerDependency |
| 28 |
{ |
| 29 |
private String[] _jarFiles = new String[]{"annogen-*", "axiom-api-*", "axiom-impl-*", |
| 30 |
"axis2-adb-*", "axis2-codegen-*", "axis2-java2wsdl-*","axis2-jibx-*", "axis2-kernel-*", "axis2-soapmonitor-*", |
| 31 |
"axis2-xmlbeans-*", "backport-util-concurrent-*", "commons-codec-*", "commons-fileupload-*", |
| 32 |
"commons-httpclient-*", "commons-logging-*","geronimo-spec-jms-*", |
| 33 |
"jaxen-*", "jibx-run-*", "neethi-*", "stax-api-*", "wstx-asl-*", "xbean-*", "xercesImpl-*", |
| 34 |
"xml-apis-*", "XmlSchema-*"}; |
| 35 |
|
| 36 |
private String[] _marFiles = new String[]{ |
| 37 |
"addressing-*", "soapmonitor-*" |
| 38 |
}; |
| 39 |
|
| 40 |
private List _filesToCopy = new LinkedList(); |
| 41 |
|
| 42 |
public String validateSoapServerHome(String serverHome) |
| 43 |
{ |
| 44 |
if(serverHome == null || serverHome.length() == 0) |
| 45 |
return Messages.CODE_GEN_AXIS2_PROJECT_DIR; |
| 46 |
|
| 47 |
File serverHomeDir = new File(serverHome); |
| 48 |
if(!serverHomeDir.exists()){ |
| 49 |
return NLS.bind(Messages.CODE_GEN_AXIS2_LOCATION_ERROR, serverHome); |
| 50 |
} |
| 51 |
|
| 52 |
File libDir = new File(serverHome+File.separatorChar+"lib"); |
| 53 |
if(!libDir.exists()){ |
| 54 |
return NLS.bind(Messages.CODE_GEN_AXIS2_LIB_LOC_ERROR, serverHome+File.separatorChar+"lib"); |
| 55 |
} |
| 56 |
|
| 57 |
File[] allJarFiles = libDir.listFiles(new CustomFileFilter("jar")); |
| 58 |
for(int i=0;i<_jarFiles.length;i++) |
| 59 |
{ |
| 60 |
String pattern = _jarFiles[i].substring(0,_jarFiles[i].indexOf("-*")); |
| 61 |
boolean jarFileFound = false; |
| 62 |
for(int j=0;j<allJarFiles.length;j++) |
| 63 |
{ |
| 64 |
if(allJarFiles[j].getName().startsWith(pattern)) |
| 65 |
{ |
| 66 |
jarFileFound = true; |
| 67 |
_filesToCopy.add(allJarFiles[j].getAbsolutePath()); |
| 68 |
break; |
| 69 |
} |
| 70 |
} |
| 71 |
if(!jarFileFound){ |
| 72 |
return NLS.bind(Messages.CODE_GEN_INVALID_JAR_PATTER, pattern); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
File modulesDir = new File(serverHome+File.separatorChar+"repository"+ File.separatorChar+"modules"); |
| 77 |
if(!modulesDir.exists()){ |
| 78 |
return NLS.bind(Messages.CODE_GEN_AXIS2_LIB_LOC_ERROR, serverHome+File.separatorChar+"repository"+ File.separatorChar+"modules"); |
| 79 |
} |
| 80 |
|
| 81 |
File[] allMarFiles = modulesDir.listFiles(new CustomFileFilter("mar")); |
| 82 |
for(int i=0;i<_marFiles.length;i++) |
| 83 |
{ |
| 84 |
String pattern = _marFiles[i].substring(0,_marFiles[i].indexOf("-*")); |
| 85 |
boolean marFileFound = false; |
| 86 |
for(int j=0;j<allMarFiles.length;j++) |
| 87 |
{ |
| 88 |
if(allMarFiles[j].getName().startsWith(pattern)) |
| 89 |
{ |
| 90 |
marFileFound = true; |
| 91 |
_filesToCopy.add(allMarFiles[j].getAbsolutePath()); |
| 92 |
break; |
| 93 |
} |
| 94 |
} |
| 95 |
if(!marFileFound){ |
| 96 |
return NLS.bind(Messages.CODE_GEN_INVALID_MAR_PATTER, pattern); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
return null; |
| 101 |
} |
| 102 |
|
| 103 |
public String[] getFilesToCopy() |
| 104 |
{ |
| 105 |
return (String[])_filesToCopy.toArray(new String[_filesToCopy.size()]); |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Returns the absolute path of the lib folder. |
| 110 |
*/ |
| 111 |
/* public String getServerLibLocation(String serverName){ |
| 112 |
String serverLocation = serverName; |
| 113 |
if(!serverLocation.endsWith(File.separator)){ |
| 114 |
serverLocation+=File.separator; |
| 115 |
} |
| 116 |
return serverLocation+"lib"; |
| 117 |
} |
| 118 |
*/ |
| 119 |
/** |
| 120 |
* Returns the absolute path of the modules folder. |
| 121 |
*/ |
| 122 |
/* public String getServerModulesLocation(String serverName){ |
| 123 |
String serverLocation = serverName; |
| 124 |
if(!serverLocation.endsWith(File.separator)){ |
| 125 |
serverLocation+=File.separator; |
| 126 |
} |
| 127 |
return serverLocation+"repository"+File.separator+"modules"; |
| 128 |
|
| 129 |
} |
| 130 |
*/ |
| 131 |
} |
| 132 |
|
| 133 |
class CustomFileFilter implements FileFilter |
| 134 |
{ |
| 135 |
String fileExtension; |
| 136 |
|
| 137 |
CustomFileFilter(String extension){ |
| 138 |
fileExtension = extension; |
| 139 |
} |
| 140 |
public boolean accept(File pathname) |
| 141 |
{ |
| 142 |
if(!pathname.isFile()) |
| 143 |
return false; |
| 144 |
return pathname.getName().endsWith(fileExtension); |
| 145 |
} |
| 146 |
} |