Skip to content

Commit

Permalink
Merge pull request #364 from phantomjinx/TEIIDDES-2137
Browse files Browse the repository at this point in the history
TEIIDDES-2137: Migrate jar libraries to their own plugin and download th...
  • Loading branch information
blafond committed May 29, 2014
2 parents 79a61a8 + 44269e7 commit 5a65161
Show file tree
Hide file tree
Showing 60 changed files with 675 additions and 147 deletions.
6 changes: 6 additions & 0 deletions features/org.teiid.designer.feature/feature.xml
Expand Up @@ -651,4 +651,10 @@
install-size="0"
version="0.0.0"/>

<plugin
id="org.teiid.designer.webservice.lib"
download-size="0"
install-size="0"
version="0.0.0"/>

</feature>
Expand Up @@ -75,4 +75,13 @@ public interface StringConstants {
*/
String FORWARD_SLASH = "/"; //$NON-NLS-1$

/**
* Back slash used in regular expressions
*/
String DOUBLE_BACK_SLASH = "\\"; //$NON-NLS-1$

/**
* Equals
*/
String EQUALS = "="; //$NON-NLS-1$
}
3 changes: 2 additions & 1 deletion plugins/org.teiid.designer.dqp.ui/META-INF/MANIFEST.MF
Expand Up @@ -73,6 +73,7 @@ Require-Bundle: org.eclipse.ui.views;bundle-version="[3.6.100,4.0.0)",
org.eclipse.ui.navigator;bundle-version="[3.5.200,4.0.0)",
org.jboss.ide.eclipse.as.ui;bundle-version="[2.4.0,4.0.0)",
org.jboss.ide.eclipse.as.core;bundle-version="[2.4.0,4.0.0)",
org.teiid.designer.spi;bundle-version="[8.1.0,9.0.0)"
org.teiid.designer.spi;bundle-version="[8.1.0,9.0.0)",
org.teiid.designer.webservice.lib;bundle-version="[8.5.0,9.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Expand Up @@ -9,7 +9,6 @@

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -33,7 +32,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -47,23 +45,25 @@
import org.eclipse.xsd.util.XSDParser;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.core.designer.util.FileUtils;
import org.teiid.core.designer.util.StringConstants;
import org.teiid.core.designer.util.TempDirectory;
import org.teiid.designer.core.ModelerCore;
import org.teiid.designer.core.types.DatatypeConstants;
import org.teiid.designer.core.workspace.ModelUtil;
import org.teiid.designer.runtime.ui.wizards.webservices.WarDeploymentInfoPanel;
import org.teiid.designer.sdt.ModelerSdtPlugin;
import org.teiid.designer.vdb.ui.util.VdbResourceFinder;
import org.teiid.designer.webservice.WebServicePlugin;
import org.teiid.designer.webservice.gen.BasicWsdlGenerator;
import org.teiid.designer.webservice.lib.WebServiceLibConstants;
import org.teiid.designer.webservice.lib.WebServiceLibPlugin;
import org.teiid.designer.webservice.util.AntTasks;

/**
* This is the default implementation of a WebArchiveBuilder.
*
* @since 8.0
*/
public class DefaultWebArchiveBuilderImpl implements WebArchiveBuilder {
public class DefaultWebArchiveBuilderImpl implements WebArchiveBuilder, WebServiceLibConstants, StringConstants {

private IPath webServicePluginPath = null;
private List<String> ports = new ArrayList<String>();
Expand Down Expand Up @@ -127,8 +127,8 @@ public IStatus validateContextName( String contextName ) {
final URLValidator urlValidator = new URLValidator();

// Check for invalid characters
String[] invalidChars = new String[] {"/" //$NON-NLS-1$
, "\\" //$NON-NLS-1$
String[] invalidChars = new String[] {FORWARD_SLASH
, DOUBLE_BACK_SLASH
, CoreStringUtil.Constants.SPACE};
final String invalidChar = validateInvalidCharactersInContextName(contextName, invalidChars);

Expand Down Expand Up @@ -190,7 +190,7 @@ public IStatus createWebArchive( Properties properties,

// Get the build directory and create it if it doesn't already
// exist.
final String webServicePluginPath = getWSPluginInstallPath().toOSString();
final String webServicePluginPath = WebServiceLibPlugin.getDefault().getInstallPath().toOSString();
final String buildDirectoryName = webServicePluginPath + File.separator + WebArchiveBuilderConstants.BUILD_DIR;
File buildDirectory = new File(buildDirectoryName);
buildDirectory.mkdir();
Expand All @@ -210,20 +210,20 @@ public IStatus createWebArchive( Properties properties,
final File contextDirectory = new File(contextDirectoryName);
contextDirectory.mkdir();
// Create the images directory.
final String imagesDirectoryName = contextDirectoryName + File.separator + "images"; //$NON-NLS-1$
final String imagesDirectoryName = contextDirectoryName + File.separator + IMAGES;
final File imagesDirectory = new File(imagesDirectoryName);
imagesDirectory.mkdir();
// Create the WEB-INF directory.
final String webInfDirectoryName = contextDirectoryName + File.separator + "WEB-INF"; //$NON-NLS-1$
final String webInfDirectoryName = contextDirectoryName + File.separator + WEB_INF;
final File webInfDirectory = new File(webInfDirectoryName);
webInfDirectory.mkdir();
// Create the WEB-INF/wsdl directory.
final String webInfWsdlDirectoryName = webInfDirectoryName + File.separator + "wsdl"; //$NON-NLS-1$
final String webInfWsdlDirectoryName = webInfDirectoryName + File.separator + WSDL;
final File webInfWsdlDirectory = new File(webInfWsdlDirectoryName);
// Create the classes directory.
final String webInfClassesDirectoryName = webInfDirectoryName + File.separator + "classes"; //$NON-NLS-1$
final String webInfClassesDirectoryName = webInfDirectoryName + File.separator + CLASSES;
// Create the WEB-INF/lib directory.
final String webInfLibDirectoryName = webInfDirectoryName + File.separator + "lib"; //$NON-NLS-1$
final String webInfLibDirectoryName = webInfDirectoryName + File.separator + LIB;
final File webInfClassesDirectory = new File(webInfClassesDirectoryName);
final File webInfLibDirectory = new File(webInfLibDirectoryName);
webInfLibDirectory.mkdir();
Expand Down Expand Up @@ -258,7 +258,7 @@ public IStatus createWebArchive( Properties properties,

monitor.subTask(TASK_CREATING_WAR_ARCHIVE);
// ZIP everything in the context directory into the new WAR file.
final String warFileName = tempDirectoryName + File.separator + contextName + ".war"; //$NON-NLS-1$
final String warFileName = tempDirectoryName + File.separator + contextName + DOT_WAR;
AntTasks.zip(contextDirectoryName, warFileName);
monitor.worked(20);

Expand All @@ -273,7 +273,7 @@ public IStatus createWebArchive( Properties properties,
// Move the temporary WAR file to its destination.
final File warFile = new File(warFileName);
final String newWarFileName = getFileName((String)properties.get(WebArchiveBuilderConstants.PROPERTY_WAR_FILE_SAVE_LOCATION),
contextName + ".war"); //$NON-NLS-1$
contextName + DOT_WAR);
File newWarFile = new File(newWarFileName);
if (newWarFile.exists()) {
if (!newWarFile.delete()) {
Expand Down Expand Up @@ -323,7 +323,7 @@ public boolean targetWarFileExists( Properties properties ) {
}

final String newWarFileName = getFileName((String)properties.get(WebArchiveBuilderConstants.PROPERTY_WAR_FILE_SAVE_LOCATION),
contextName + ".war"); //$NON-NLS-1$
contextName + DOT_WAR);

fileExists = (new File(newWarFileName)).exists();

Expand Down Expand Up @@ -375,7 +375,7 @@ private String getFileName( String path,
String name ) {

String fileName = path;
if (!fileName.endsWith("/") && !fileName.endsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$
if (!fileName.endsWith(FORWARD_SLASH) && !fileName.endsWith(DOUBLE_BACK_SLASH)) {

fileName = fileName + File.separator;
}
Expand All @@ -391,13 +391,12 @@ private String getFileName( String path,
* @param webInfDirectory
* @since 7.1
*/
private void getWebFiles( File contextDirectory,
File webInfDirectory,
private void getWebFiles( File contextDirectory, 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 String webLibPath = WebServiceLibPlugin.getDefault().getSoapWebLibDirectoryPath();
final String webAppsDirectoryName = webLibPath + File.separator + WEBAPPS;
final File webAppsDirectory = new File(webAppsDirectoryName);
FileUtils.copyRecursively(webAppsDirectory, contextDirectory, null, false);

Expand Down Expand Up @@ -425,7 +424,7 @@ private void replaceWebXmlVariables( String webInfDirectoryName,
String contextName ) throws Exception {

// Replace variables in the web.xml file.
File webXmlFile = new File(webInfDirectoryName + File.separator + "web.xml"); //$NON-NLS-1$
File webXmlFile = new File(webInfDirectoryName + File.separator + WEB_XML);

// Update for Basic Auth if HTTPBasic security is selected
if (securityCredentials.hasType(WarDeploymentInfoPanel.BASIC)) {
Expand Down Expand Up @@ -453,7 +452,7 @@ private void replaceJBossWebXmlVariables( String webInfDirectoryName,
String securityDomain ) {

// Replace variables in the jboss-web.xml file.
File jbossWebXmlFile = new File(webInfDirectoryName + File.separator + "jboss-web.xml"); //$NON-NLS-1$
File jbossWebXmlFile = new File(webInfDirectoryName + File.separator + JBOSS_WEB_XML);

String securityDomainNode = "<security-domain>java:/jaas/" + securityDomain + "</security-domain>"; //$NON-NLS-1$ //$NON-NLS-2$

Expand All @@ -473,7 +472,7 @@ private void replaceJBossWSCXFVariables( String webInfDirectoryName,
Properties properties, SecurityCredentials securityCredentials ) {

// Replace variables in the jbossws-cxf.xml file.
File jbossWSCxfXMLFile = new File(webInfDirectoryName + File.separator + "jbossws-cxf.xml"); //$NON-NLS-1$
File jbossWSCxfXMLFile = new File(webInfDirectoryName + File.separator + JBOSS_WEB_CXF);

AntTasks.replace(jbossWSCxfXMLFile, "${jaxws.endpoint}", createEndpointTags(properties, securityCredentials, getPorts())); //$NON-NLS-1$

Expand All @@ -495,11 +494,11 @@ private void createPropertiesFile( File webInfClassesDirectory,
Properties properties ) throws IOException {

// Create teiidsoap.properties file
File teiisSoapProperties = new File(webInfClassesDirectory + File.separator + "teiidsoap.properties"); //$NON-NLS-1$
File teiisSoapProperties = new File(webInfClassesDirectory + File.separator + TEIID_SOAP_PROPS);
String jndiValue = properties.getProperty(WebArchiveBuilderConstants.PROPERTY_JNDI_NAME);

if (jndiValue != null && !jndiValue.startsWith(JNDI_PREFIX)) {
jndiValue = JNDI_PREFIX + "/" + jndiValue; //$NON-NLS-1$
jndiValue = JNDI_PREFIX + FORWARD_SLASH + jndiValue;
}

FileWriter fstream = null;
Expand All @@ -511,9 +510,9 @@ private void createPropertiesFile( File webInfClassesDirectory,
Iterator it = operationToProcedureMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
out.write(pairs.getKey() + "=" + pairs.getValue() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
out.write(pairs.getKey() + EQUALS + pairs.getValue() + NEW_LINE);
}
out.write(WebArchiveBuilderConstants.PROPERTY_JNDI_NAME + "=" + jndiValue); //$NON-NLS-1$
out.write(WebArchiveBuilderConstants.PROPERTY_JNDI_NAME + EQUALS + jndiValue);
} finally {
// Close the output stream
out.close();
Expand Down Expand Up @@ -613,34 +612,6 @@ private boolean isUseMTOM( Properties properties ) {
return useMotem == null ? false : useMotem.equals(Boolean.TRUE);
}

/**
* Return the path to the lib directory
*
* @return
* @throws Exception
* @since 7.1
*/
private String getWebLibDirectoryPath() throws Exception {
final String webServicePluginPath = getWSPluginInstallPath().toOSString();
final String webServiceLibFolder = webServicePluginPath + File.separator + "war_resources"; //$NON-NLS-1$
if (new File(webServiceLibFolder).exists()) {
return webServiceLibFolder;
}
final String msg = WebServicePlugin.Util.getString("DefaultWebArchiveBuilderImpl.web_lib_directory_does_not_exist", webServiceLibFolder); //$NON-NLS-1$
WebServicePlugin.Util.log(IStatus.ERROR, msg);
throw new FileNotFoundException(msg);
}

public IPath getWSPluginInstallPath() throws IOException {
if (this.webServicePluginPath == null) {
URL url = FileLocator.find(WebServicePlugin.getInstance().getBundle(), new Path(""), null); //$NON-NLS-1$
url = FileLocator.toFileURL(url);
this.webServicePluginPath = new Path(url.getFile());
}

return (IPath)this.webServicePluginPath.clone();
}

class URLValidator implements Serializable {
/**
*/
Expand Down Expand Up @@ -706,7 +677,7 @@ public boolean generateWsdl( Properties properties,
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$
File xsdCopy = new File(webinfWsdlFolder.getPath() + FORWARD_SLASH + fileNameWithExtension);
// Replace the schemaLocation of the global data
// types schema import with the relative path to xsd
AntTasks.replace(xsdCopy,
Expand All @@ -732,7 +703,7 @@ public boolean generateWsdl( Properties properties,
wsdlGenerator.setTargetNamespace(tns);
wsdlGenerator.setUrlRootForReferences(CoreStringUtil.Constants.EMPTY_STRING);
wsdlGenerator.setUrlSuffixForReferences(CoreStringUtil.Constants.EMPTY_STRING);
wsdlGenerator.setUrlForWsdlService("http://" + host + ":" + port + "/" + contextName + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
wsdlGenerator.setUrlForWsdlService("http://" + host + ":" + port + FORWARD_SLASH + contextName + FORWARD_SLASH); //$NON-NLS-1$ //$NON-NLS-2$
final IStatus status = wsdlGenerator.generate(new NullProgressMonitor());

// nothing more to do if an error is expected
Expand Down

0 comments on commit 5a65161

Please sign in to comment.