Permalink
Browse files

deployer done

  • Loading branch information...
1 parent 63d7a65 commit a15ed9e427b85dfb1aa280d7304d2f261ac1363f afogleson committed Mar 19, 2012
Showing with 2,475 additions and 130 deletions.
  1. +66 −9 src/main/java/com/guidewire/accel/deployment/Deployer.java
  2. +74 −0 src/main/java/com/guidewire/accel/deployment/impl/RpcWebServiceComponent.java
  3. +0 −28 src/main/java/com/guidewire/accel/deployment/impl/WebServiceComponent.java
  4. +25 −0 src/main/java/com/guidewire/accel/parser/AcceleratorParser.java
  5. +2 −2 src/main/java/com/guidewire/accel/parser/extensions/entity/model/EntityModel.java
  6. +18 −8 src/main/java/com/guidewire/accel/parser/webservice/rpc/pojo/WebServiceSetting.java
  7. +15 −1 src/main/java/com/guidewire/accel/parser/webservice/rpc/pojo/Webservice.java
  8. +756 −32 src/main/java/com/guidewire/accelerator/deployment/Accelerator.java
  9. +1 −1 src/main/java/com/guidewire/accelerator/deployment/AcceleratorDocument.java
  10. +1 −1 src/main/java/com/guidewire/accelerator/deployment/PluginParam.java
  11. +1,364 −33 src/main/java/com/guidewire/accelerator/deployment/impl/AcceleratorImpl.java
  12. +52 −5 src/main/resources/deployment.xsd
  13. +4 −3 src/test/java/com/guidewire/com/guidewire/accel/deployment/impl/AcceleratorParserTest.java
  14. +3 −3 src/test/java/com/guidewire/com/guidewire/accel/deployment/impl/ComponentListTest.java
  15. +2 −2 src/test/java/com/guidewire/com/guidewire/accel/deployment/impl/MessagingConfigParserTest.java
  16. +86 −0 src/test/java/com/guidewire/com/guidewire/accel/deployment/impl/WebServiceModelTest.java
  17. +4 −0 src/test/resources/accelerator/deployment.xml
  18. +1 −1 src/test/resources/product/modules/configuration/config/locale/en_GB/display.properties
  19. +1 −1 src/test/resources/product/modules/configuration/config/locale/en_US/display.properties
@@ -1,32 +1,89 @@
package com.guidewire.accel.deployment;
+import com.guidewire.accel.deployment.impl.*;
+import com.guidewire.accel.deployment.util.ComponentList;
+import com.guidewire.accel.parser.AcceleratorParser;
+
import java.util.List;
/**
* User: afogleson
* Date: 3/10/12
* Time: 12:21 PM
- * <p/>
- * This is essentially a chain of installers to do the various installs needed for an accelerator.
- * Essentially you pass in a list of components and this chain will work through that list deploying them
+ *
*/
public class Deployer {
/**
- * The parser is responsible for finding and creating all the components. The deployer is responsible
- * for ordering them, then deploying them in the correct order.
+ * The parser is responsible for finding and creating all the components. The ComponentList is responsible
+ * for ordering them, then the deployer is responsible for deploying them in the correct order.
*
- * @param components a List of all the @DeployableComponents that were found through parsing.
+ * @param components a @see ComponentList of all the @see DeployableComponents that were found through parsing.
+ * @Return True is the accelerator deployed, else false.
* @throws InvalidComponentException
*/
- public void deploy(List<DeployableComponent> components) throws InvalidComponentException {
+ public boolean deploy(ComponentList components) throws InvalidComponentException {
//I am not sure how to handle a failure mid stream....
//And we need some ordering here. we should probably not just run through the components
//Especially since you could have ant/ivy dependent on a maven build, and a library
//component dependent on ant or maven...
- for (DeployableComponent component : components) {
- component.deploy();
+
+ //first get all the maven build components and deploy them.
+ boolean isDeployed = true;
+ for(DeployableComponent component : components.getComponentList("mavenBuildComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ //then do all our ant components
+ for(DeployableComponent component : components.getComponentList("antBuildComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ //deploy the libraries created from these
+ for(DeployableComponent component : components.getComponentList("libraryComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ //the remainder are less important, but do the ones with the highest possibility of failure
+ for(DeployableComponent component : components.getComponentList("dataExtensionComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ for(DeployableComponent component : components.getComponentList("messagingComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ for(DeployableComponent component : components.getComponentList("pluginComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ for(DeployableComponent component : components.getComponentList("rpcWebServiceComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ for(DeployableComponent component : components.getComponentList("displayKeyComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ for(DeployableComponent component : components.getComponentList("gosuComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
+ }
+ for(DeployableComponent component : components.getComponentList("pcfComponent")) {
+ if(isDeployed) {
+ isDeployed = component.deploy();
+ }
}
+ return isDeployed;
}
}
@@ -0,0 +1,74 @@
+package com.guidewire.accel.deployment.impl;
+
+import com.guidewire.accel.deployment.DeployableComponent;
+import com.guidewire.accel.deployment.util.FileDeployer;
+import com.guidewire.accel.parser.webservice.rpc.pojo.WebService;
+import com.guidewire.accel.util.AcceleratorHelper;
+
+import java.io.File;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: afogleson
+ * Date: 3/10/12
+ * Time: 1:59 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class RpcWebServiceComponent implements DeployableComponent {
+
+ private WebService webService;
+
+ @Override
+ public boolean deploy() {
+ boolean deployed = true;
+ //webServices deploy to $PRODUCT_ROOT/modules/configuration/config/webservices/$NAME.xml
+ StringBuilder sb = new StringBuilder();
+ sb.append(AcceleratorHelper.getInstance().getProductRoot().getAbsolutePath());
+ sb.append(File.separator);
+ sb.append("modules");
+ sb.append(File.separator);
+ sb.append("configuration");
+ sb.append(File.separator);
+ sb.append("config");
+ sb.append(File.separator);
+ sb.append("webservices");
+ sb.append(File.separator);
+
+ File outDir = new File(sb.toString());
+ if(!outDir.exists()) {
+ try {
+ outDir.mkdirs();
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ deployed = false;
+ }
+ }
+ if(deployed) {
+ try {
+ File outFile = new File(outDir.getAbsolutePath() + File.separator + webService.getName() + ".xml");
+ String xml = webService.asXML();
+ FileDeployer.writeStringToFile(xml, outFile);
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ deployed = false;
+ }
+ }
+ return deployed;
+ }
+
+ @Override
+ public boolean isValid() {
+ return true;
+ }
+
+ @Override
+ public String getComponentName() {
+ return "rpcWebServiceComponent";
+ }
+
+ public void setWebService(WebService webService) {
+ this.webService = webService;
+ }
+}
@@ -1,28 +0,0 @@
-package com.guidewire.accel.deployment.impl;
-
-import com.guidewire.accel.deployment.DeployableComponent;
-
-/**
- * Created with IntelliJ IDEA.
- * User: afogleson
- * Date: 3/10/12
- * Time: 1:59 PM
- * To change this template use File | Settings | File Templates.
- */
-public class WebServiceComponent implements DeployableComponent {
-
- @Override
- public boolean deploy() {
- return false;
- }
-
- @Override
- public boolean isValid() {
- return true;
- }
-
- @Override
- public String getComponentName() {
- return "webServiceComponent";
- }
-}
@@ -5,6 +5,8 @@
import com.guidewire.accel.deployment.util.ComponentList;
import com.guidewire.accel.parser.plugin.pojo.GosuPlugin;
import com.guidewire.accel.parser.plugin.pojo.JavaPlugin;
+import com.guidewire.accel.parser.webservice.rpc.pojo.WebService;
+import com.guidewire.accel.parser.webservice.rpc.pojo.WebServiceSetting;
import com.guidewire.accel.util.FileUtil;
import com.guidewire.accel.util.PluginParam;
import com.guidewire.accelerator.deployment.Accelerator;
@@ -223,6 +225,29 @@ public void parseAccelerator() {
}
addToComponents(component);
}
+ for(Accelerator.RpcWebService ws : accel.getRpcWebServiceArray()) {
+ RpcWebServiceComponent component = new RpcWebServiceComponent();
+ WebService service = new WebService();
+ service.setName(ws.getName());
+ service.setWsdlLocation(ws.getWsdlLocation());
+ if(ws.getSettingArray() != null && ws.getSettingArray().length > 0) {
+ for(Accelerator.RpcWebService.Setting s : ws.getSettingArray()) {
+ WebServiceSetting setting = new WebServiceSetting();
+ setting.setCallTimeout(s.getCallTimeout());
+ setting.setEnv(s.getEnv());
+ setting.setServer(s.getServer());
+ setting.setOverrideEnabled(s.getOverrideEnabled());
+ setting.setOverrideUrl(s.getOverrideUrl());
+ setting.setServiceName(s.getServiceName());
+ setting.setAuthenticationType(s.getAuthentication().getAuthenticationType());
+ setting.setUsername(s.getAuthentication().getUsername());
+ setting.setPassword(s.getAuthentication().getPassword());
+ service.addToSettings(setting);
+ }
+ }
+ component.setWebService(service);
+ addToComponents(component);
+ }
if(accel.getDataExtension() != null) {
Accelerator.DataExtension comp = accel.getDataExtension();
@@ -3,11 +3,11 @@
import com.guidewire.accel.parser.model.Model;
/**
- * Created by IntelliJ IDEA.
+ *
* User: tp23161
* Date: 14/03/12
* Time: 12:55
- * To change this template use File | Settings | File Templates.
+ *
*/
public class EntityModel extends Model {
@@ -32,7 +32,25 @@ public String asXML() {
sb.append(callTimeout);
sb.append("\"");
}
+ if(env != null && env.trim().length() > 0) {
+ sb.append("\n env=\"");
+ sb.append(env);
+ sb.append("\"");
+ }
+ if(server != null && server.trim().length() > 0) {
+ sb.append("\n server=\"");
+ sb.append(server);
+ sb.append("\"");
+ }
sb.append(">\n");
+ if(authenticationType != null && authenticationType.trim().length() > 0) {
+ sb.append(" <http-authentication");
+ sb.append("\n password=\"");
+ sb.append(password);
+ sb.append("\"\n username=\"");
+ sb.append(username);
+ sb.append("\"/>\n");
+ }
if(overrideEnabled || (overrideUrl != null && overrideUrl.trim().length() > 0)) {
sb.append(" <service\n override-enable=\"");
sb.append(overrideEnabled);
@@ -42,14 +60,6 @@ public String asXML() {
sb.append("\"");
sb.append("\n service-name=\"");
sb.append(serviceName);
- sb.append("/>\n");
- }
- if(authenticationType != null && authenticationType.trim().length() > 0) {
- sb.append(" <http-authentication");
- sb.append("\n password=\"");
- sb.append(password);
- sb.append("\"\n username=\"");
- sb.append(username);
sb.append("\"/>\n");
}
sb.append(" </settings>\n");
@@ -9,7 +9,7 @@
* Time: 9:59 PM
* To change this template use File | Settings | File Templates.
*/
-public class Webservice {
+public class WebService {
private String name;
private String wsdlLocation;
@@ -34,6 +34,17 @@ public void setWsdlLocation(String wsdlLocation) {
public void addToSettings(WebServiceSetting setting) {
settings.add(setting);
}
+
+ private boolean hasDefaultSetting() {
+ boolean hasDefault = false;
+ for(WebServiceSetting ws : settings) {
+ if((ws.getServer() == null || ws.getServer().trim().length() == 0) &&
+ (ws.getEnv() == null || ws.getEnv().trim().length() == 0)) {
+ hasDefault = true;
+ }
+ }
+ return hasDefault;
+ }
public String asXML() {
StringBuilder sb = new StringBuilder();
@@ -43,6 +54,9 @@ public String asXML() {
sb.append("\"\n wsdl-location=\"");
sb.append(wsdlLocation);
sb.append("\">\n");
+ if(settings != null && settings.size() > 0 && !hasDefaultSetting()) {
+ sb.append(" <settings/>\n");
+ }
for(WebServiceSetting ws : settings) {
sb.append(ws.asXML());
}
Oops, something went wrong.

0 comments on commit a15ed9e

Please sign in to comment.