Skip to content

Commit

Permalink
Merge pull request #270 from tejones/teiiddes-1958
Browse files Browse the repository at this point in the history
teiiddes-1958
  • Loading branch information
blafond committed Dec 3, 2013
2 parents ce89134 + 399b835 commit 472cc11
Show file tree
Hide file tree
Showing 2 changed files with 803 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ public IStatus createWebArchive( Properties properties,
// Create the WEB-INF/wsdl directory.
final String webInfWsdlDirectoryName = webInfDirectoryName + File.separator + "wsdl"; //$NON-NLS-1$
final File webInfWsdlDirectory = new File(webInfWsdlDirectoryName);
webInfWsdlDirectory.mkdir();
// Create the classes directory.
final String webInfClassesDirectoryName = webInfDirectoryName + File.separator + "classes"; //$NON-NLS-1$
// Create the WEB-INF/wsdl directory.
// Create the WEB-INF/lib directory.
final String webInfLibDirectoryName = webInfDirectoryName + File.separator + "lib"; //$NON-NLS-1$
final File webInfClassesDirectory = new File(webInfClassesDirectoryName);
final File webInfLibDirectory = new File(webInfLibDirectoryName);
Expand All @@ -233,11 +232,11 @@ public IStatus createWebArchive( Properties properties,

monitor.subTask(TASK_CREATING_WSDL_FILE);
// Create WSDL file
generateWsdl(properties, webInfWsdlDirectory);
boolean containsGlobalDataTypes = generateWsdl(properties, webInfWsdlDirectory);

monitor.subTask(TASK_COPYING_FILES);
// Copy the Web files.
getWebFiles(contextDirectory, webInfDirectory);
getWebFiles(contextDirectory, webInfDirectory, containsGlobalDataTypes);

// Encapsulate the security properties in order to ensure they are valid
SecurityCredentials securityCredentials = new SecurityCredentials(properties);
Expand Down Expand Up @@ -393,13 +392,21 @@ private String getFileName( String path,
* @since 7.1
*/
private void getWebFiles( File contextDirectory,
File webInfDirectory ) throws Exception {
File webInfDirectory,
boolean containsGlobalDataTypes) throws Exception {

// Copy all of the Web files
final String webLibPath = getWebLibDirectoryPath();
final String webAppsDirectoryName = webLibPath + File.separator + "webapps"; //$NON-NLS-1$
final File webAppsDirectory = new File(webAppsDirectoryName);
FileUtils.copyRecursively(webAppsDirectory, contextDirectory, null, false);

//Delete builtInDataType.xsd if not applicable to this service
if (!containsGlobalDataTypes){
File builtInDataTypeSchemaFile = new File(webInfDirectory.getPath() + "/wsdl/" + DatatypeConstants.DATATYPES_MODEL_FILE_NAME); //$NON-NLS-1$
boolean deleted = builtInDataTypeSchemaFile.delete();
}

}

/**
Expand Down Expand Up @@ -655,7 +662,7 @@ public boolean isValidValue( Object value ) {
}
}

public void generateWsdl( Properties properties,
public boolean generateWsdl( Properties properties,
File webinfWsdlFolder) throws IOException, CoreException {

BasicWsdlGenerator wsdlGenerator = new BasicWsdlGenerator();
Expand All @@ -670,6 +677,7 @@ public void generateWsdl( Properties properties,
String vdbFileName = properties.getProperty(WebArchiveBuilderConstants.PROPERTY_VDB_FILE_NAME);
IPath vdbPath = new Path(vdbFileName);
IFile vdbFile = ModelerCore.getWorkspace().getRoot().getFile(vdbPath);
boolean hasGlobalDataType = false;

VdbResourceFinder vdbResourceFinder = new VdbResourceFinder(vdbFile);

Expand All @@ -693,15 +701,13 @@ public void generateWsdl( Properties properties,

// Check for an import of the global data types schema
if (containsGlobalDataTypeImport(xsdSchema)) {
// Copy the builtInDataTypes.xsd file to the war
Resource builtInDataypesResource = ModelerSdtPlugin.getBuiltInTypesResource();
FileUtils.copy(new File(builtInDataypesResource.getURI().path()), webinfWsdlFolder, true);
hasGlobalDataType = true;
// Copy iResource to classesFolder and WEB-INF/wsdl
File xsd = new File(fullFilePath);
FileUtils.copy(xsd, webinfWsdlFolder, true);
// Get handle to new file in wsdl folder
File xsdCopy = new File(webinfWsdlFolder.getPath() + "/" + fileNameWithExtension); //$NON-NLS-1$
// Replace the schemaLocation of the global data
// Replace the schemaLocation of the global data
// types schema import with the relative path to xsd
AntTasks.replace(xsdCopy,
"schemaLocation=\"http://www.metamatrix.com/metamodels/SimpleDatatypes-instance\"", //$NON-NLS-1$
Expand Down Expand Up @@ -751,6 +757,8 @@ public void generateWsdl( Properties properties,
} catch (CoreException e) {
throw new RuntimeException(e.getMessage());
}

return hasGlobalDataType;

}

Expand Down

0 comments on commit 472cc11

Please sign in to comment.