Skip to content

Commit

Permalink
Merge pull request #109 from tejones/teiiddes-1460
Browse files Browse the repository at this point in the history
teiiddes-1460
  • Loading branch information
blafond committed Feb 18, 2013
2 parents 3cf5a85 + b159a22 commit b3cfb55
Show file tree
Hide file tree
Showing 15 changed files with 694 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static org.teiid.designer.runtime.extension.rest.RestModelExtensionConstants.NAMESPACE_PROVIDER;
import static org.teiid.designer.runtime.ui.DqpUiConstants.UTIL;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand All @@ -34,6 +35,7 @@
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.teiid.core.designer.ModelerCoreException;
import org.teiid.core.designer.util.CoreStringUtil;
import org.teiid.core.designer.util.FileUtils;
import org.teiid.core.designer.util.I18nUtil;
Expand All @@ -55,7 +57,6 @@
import org.teiid.designer.ui.common.eventsupport.SelectionUtilities;
import org.teiid.designer.ui.viewsupport.ModelIdentifier;
import org.teiid.designer.vdb.Vdb;
import org.teiid.designer.vdb.Vdb;
import org.teiid.designer.vdb.VdbModelEntry;


Expand Down Expand Up @@ -332,9 +333,30 @@ private static String getUri( Procedure procedure ) {
return uri;
}

private static String getCharset( Procedure procedure ) {
String charset = null;

try {
// try new way first
ModelObjectExtensionAssistant assistant = (ModelObjectExtensionAssistant)ExtensionPlugin.getInstance()
.getRegistry()
.getModelExtensionAssistant(NAMESPACE_PROVIDER.getNamespacePrefix());
charset = assistant.getPropertyValue(procedure, RestModelExtensionConstants.PropertyIds.CHARSET);

if (CoreStringUtil.isEmpty(charset)) {
charset = (String)ANNOTATION_HELPER.getPropertyValueAnyCase(procedure,
ModelObjectAnnotationHelper.EXTENDED_PROPERTY_NAMESPACE
+ "CHARSET"); //$NON-NLS-1$
}
} catch (Exception e) {
UTIL.log(e);
}

return charset;
}

/**
* @param eObject
* @return
* @throws ModelerCoreException
*/
private static void createRestProcedureCollection( Procedure procedure,
Expand All @@ -345,7 +367,11 @@ private static void createRestProcedureCollection( Procedure procedure,

if (restMethod != null) {
String uri = getUri(procedure);

String charSet = getCharset(procedure);
if (charSet==null){
charSet=Charset.defaultCharset().name();
}

// the procedure is not eligible for REST exposure with a URI defined
if (uri != null) {
boolean hasReturn = false;
Expand All @@ -372,13 +398,16 @@ private static void createRestProcedureCollection( Procedure procedure,
uriParameterCount++;
}
}

restProcedure.setCharSet(charSet);
restProcedure.setRestMethod(restMethod);
restProcedure.setUri(uri);
restProcedure.setProcedureName(name);
restProcedure.setFullyQualifiedProcedureName(fullName);

// Create JSON version
RestProcedure jsonRestProcedure = new RestProcedure();
jsonRestProcedure.setCharSet(charSet);
jsonRestProcedure.setFullyQualifiedProcedureName(restProcedure.getFullyQualifiedProcedureName());
jsonRestProcedure.setModelName(restProcedure.getModelName());
jsonRestProcedure.setProcedureName(restProcedure.getProcedureName());
Expand All @@ -397,8 +426,8 @@ private static void createRestProcedureCollection( Procedure procedure,
}

if (hasReturn) {
restProcedure.setProducesAnnotation("@Produces( MediaType.APPLICATION_XML )"); //$NON-NLS-1$
jsonRestProcedure.setProducesAnnotation("@Produces( MediaType.APPLICATION_JSON )"); //$NON-NLS-1$
restProcedure.setProducesAnnotation("@Produces( MediaType.APPLICATION_XML+"+"\"; charset="+charSet+"\")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
jsonRestProcedure.setProducesAnnotation("@Produces( MediaType.APPLICATION_JSON+"+"\"; charset="+charSet+"\")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}

restfulProcedureArray.add(restProcedure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ RestWarDeploymentInfoDialog.overwriteTargetWar.message=The target WAR file alrea
RestWarDeploymentInfoDialog.warTitle=Select folder
RestWarDeploymentInfoDialog.warMessage=Select folder for WAR save location


#########################################
# RestWarDeploymentInfoPanel
#########################################
Expand All @@ -439,6 +440,19 @@ RestWarDeploymentInfoPanel.warFileSaveLocationLabel=REST WAR File Save Location:
RestWarDeploymentInfoPanel.warFileSaveLocationTooltip=REST WAR file save location folder, where the WAR file will be saved.
RestWarDeploymentInfoPanel.jndiLabel=VDB JNDI Name:
RestWarDeploymentInfoPanel.jndiTooltip=The JNDI name of the VDB data source (NOT the underlying data source JNDI name).

RestWarDeploymentInfoPanel.targetGrpPanelText=Target Data Services Platform Version
RestWarDeploymentInfoPanel.targetVersionLabel=Target Version:
RestWarDeploymentInfoPanel.targetVersionTooltip=Target Data Services version for this WAR.
RestWarDeploymentInfoPanel.81Text=Teiid 8.1 or less
RestWarDeploymentInfoPanel.82Text=Teiid 8.2 or greater
RestWarDeploymentInfoPanel.jarLocationGrpPanelText=Select Teiid Jars (Required for WAR compilation if Teiid 8.2 or greater).
RestWarDeploymentInfoPanel.engineJarLabel=teiid-engine-{version}.jar:
RestWarDeploymentInfoPanel.engineJarTooltip=Select the teiid-engine-{version}.jar file.
RestWarDeploymentInfoPanel.commonCoreJarLabel=teiid-common-core-{version}.jar:
RestWarDeploymentInfoPanel.commonCoreJarTooltip=Select the teiid-common-core-{version}.jar file.


RestWarDeploymentInfoPanel.restoreDefaultButtonText=Restore Default
RestWarDeploymentInfoPanel.restoreDefaultTooltip=This button will allow the user to populate all the inputs with default values.
RestWarDeploymentInfoPanel.browseButtonText=Browse...
Expand All @@ -451,6 +465,7 @@ RestWarDeploymentInfoPanel.vdbEditingContextErrorMessage=VDB is not valid, close
RestWarDeploymentInfoPanel.vdbEditingContextLogErrorMessage=VdbEditingContext is null.
RestWarDeploymentInfoPanel.contextErrorMessage=Enter valid context name.
RestWarDeploymentInfoPanel.jndiErrorMessage=Enter valid JNDI name.
RestWarDeploymentInfoPanel.jarLocationError=When targeting a Data Services version 8.2 or greater, the location of the Teiid Engine and Common Core jars are required for compilation of the WAR.
RestWarDeploymentInfoPanel.creatingWarFileMessage=Creating war file {0}
RestWarDeploymentInfoPanel.warFilePleaseEnterFile.message=Please enter a location to save the REST WAR file.
RestWarDeploymentInfoPanel.warFileSaveFolderNameProblem.message=The REST WAR file save location is invalid.
Expand All @@ -459,6 +474,9 @@ RestWarDeploymentInfoPanel.overwriteTargetWar.title=Overwrite existing REST WAR
RestWarDeploymentInfoPanel.overwriteTargetWar.message=The target REST WAR file already exists. Do you wish to overwrite it?
RestWarDeploymentInfoPanel.warTitle=Select folder
RestWarDeploymentInfoPanel.warMessage=Select folder for REST WAR save location
RestWarDeploymentInfoPanel.engineJarMessage=Select the Teiid Engine jar location
RestWarDeploymentInfoPanel.commonCoreJarMessage=Select the Teiid Common Core jar location
RestWarDeploymentInfoPanel.jarLocations=JAR Locations
RestWarDeploymentInfoPanel.includeJars.text=Include RESTEasy Jars in lib Folder of WAR
RestWarDeploymentInfoPanel.includeJars.tooltip=If your server installation includes RESTEasy, you should exclude them the jars from the WAR to avoid conflicts.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ interface WebServicesImages {
public static int VALIDATEROLE = 7;
public static int VALIDATEUSERNAME = 8;
public static int VALIDATEPASSWORD = 9;
/**
* @since 8.1
*/
public static int VALIDATEJARLOCATION = 10;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.teiid.designer.core.util.StringUtilities;
import org.teiid.designer.runtime.ui.wizards.webservices.util.RestProcedure;
import org.teiid.designer.runtime.ui.wizards.webservices.util.WebArchiveBuilderConstants;

Expand All @@ -29,6 +30,9 @@ public class RestWarDataserviceModel {
private String contextNameDefault;
private String jndiNameDefault;
private boolean includeJarsDefault;
private boolean version82_OrGreater;
private String engineJarLocation;
private String commonCoreJarLocation;

private IFile theVdb;
private Map<String, List<RestProcedure>> restProcedureMap;
Expand Down Expand Up @@ -264,7 +268,58 @@ public Properties getProperties() {
properties.put(WebArchiveBuilderConstants.PROPERTY_VDB_FILE_NAME, this.getVdbFile().getLocation().toOSString());
properties.put(WebArchiveBuilderConstants.PROPERTY_INCLUDE_RESTEASY_JARS, this.isIncludeJars());
properties.put(WebArchiveBuilderConstants.PROPERTY_VDB_REST_PROCEDURES, this.getRestProcedureMap());
properties.put(WebArchiveBuilderConstants.PROPERTY_8_2_OR_HIGHER, this.isVersion82_OrGreater());
properties.put(WebArchiveBuilderConstants.PROPERTY_ENGINE_JAR, this.getEngineJarLocation());
properties.put(WebArchiveBuilderConstants.PROPERTY_COMMON_CORE_JAR, this.getCommonCoreJarLocation());

return properties;
}

/**
* @return the version82_OrGreater
* @since 8.1
*/
public boolean isVersion82_OrGreater() {
return version82_OrGreater;
}

/**
* @param version82_OrGreater the version82_OrGreater to set
* @since 8.1
*/
public void setVersion82_OrGreater(boolean version82_OrGreater) {
this.version82_OrGreater = version82_OrGreater;
}

/**
* @return the engineJarLocation
* @since 8.1
*/
public String getEngineJarLocation() {
return engineJarLocation == null ? StringUtilities.EMPTY_STRING : engineJarLocation;
}

/**
* @param engineJarLocation the engineJarLocation to set
* @since 8.1
*/
public void setEngineJarLocation(String engineJarLocation) {
this.engineJarLocation = engineJarLocation;
}

/**
* @return the commonCoreJarLocation
* @since 8.1
*/
public String getCommonCoreJarLocation() {
return commonCoreJarLocation == null ? StringUtilities.EMPTY_STRING : commonCoreJarLocation;
}

/**
* @param commonCoreJarLocation the commonCoreJarLocation to set
* @since 8.1
*/
public void setCommonCoreJarLocation(String commonCoreJarLocation) {
this.commonCoreJarLocation = commonCoreJarLocation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.swt.widgets.Composite;
import org.teiid.core.designer.CoreModelerPlugin;
import org.teiid.core.designer.TeiidDesignerException;
import org.teiid.designer.core.util.StringUtilities;
import org.teiid.designer.runtime.ui.DqpUiConstants;
import org.teiid.designer.runtime.ui.wizards.webservices.util.WebArchiveBuilder;
import org.teiid.designer.runtime.ui.wizards.webservices.util.WebArchiveBuilderFactory;
Expand Down Expand Up @@ -54,7 +55,7 @@ public RestWarDeploymentInfoDataPage( Composite parent,
@Override
protected void validatePage() {

boolean isValid = validateContext() && validateJNDI() && validateWARFileFolder();
boolean isValid = validateContext() && validateJNDI() && validateWARFileFolder() && validateJarLocations() && validateEngineJarLocation() && validateCommonCoreJarLocation() ;

if (!isValid) {
setDialogMessage(status);
Expand Down Expand Up @@ -123,6 +124,55 @@ private boolean validateJNDI() {

return true;
}

/**
* validate JNDI
*
* @return boolean
* @since 7.4
*/
private boolean validateJarLocations() {



if (this.targetVersionCombo.getText().equals(_82_or_greater) &&
((this.engineJarFileLocation.getText()==null || this.engineJarFileLocation.getText().trim().equals(StringUtilities.EMPTY_STRING)) ||
(this.commonCoreJarFileLocation.getText()==null || this.commonCoreJarFileLocation.getText().trim().equals(StringUtilities.EMPTY_STRING)))){
ERROR_MESSAGE = getString("jarLocationError");//$NON-NLS-1$
createStatus(IStatus.ERROR, ERROR_MESSAGE, InternalModelerWarUiConstants.VALIDATEJARLOCATION);
return false;
}

return true;
}

/**
* validate Engine jar location
*
* @return boolean
* @since 8.1
*/
private boolean validateEngineJarLocation() {


RestWarDataserviceModel.getInstance().setEngineJarLocation(this.engineJarFileLocation.getText());

return true;
}

/**
* validate Engine jar location
*
* @return boolean
* @since 8.1
*/
private boolean validateCommonCoreJarLocation() {


RestWarDataserviceModel.getInstance().setCommonCoreJarLocation(this.commonCoreJarFileLocation.getText());

return true;
}

/**
* check to see if a war folder location exist
Expand Down
Loading

0 comments on commit b3cfb55

Please sign in to comment.