Source Code Cross Referenced for UpdateInterfaceAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » actions » iface » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl.actions.iface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl.actions.iface;
014:
015:        import java.io.File;
016:        import java.util.List;
017:
018:        import com.eviware.soapui.SoapUI;
019:        import com.eviware.soapui.impl.wsdl.WsdlInterface;
020:        import com.eviware.soapui.impl.wsdl.WsdlOperation;
021:        import com.eviware.soapui.impl.wsdl.WsdlRequest;
022:        import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
023:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequest;
024:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep;
025:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
026:        import com.eviware.soapui.model.iface.Request;
027:        import com.eviware.soapui.model.testsuite.TestCase;
028:        import com.eviware.soapui.model.testsuite.TestSuite;
029:        import com.eviware.soapui.support.UISupport;
030:        import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
031:        import com.eviware.soapui.support.xml.XmlUtils;
032:        import com.eviware.x.form.XFormDialog;
033:        import com.eviware.x.form.XFormField;
034:        import com.eviware.x.form.XFormFieldListener;
035:        import com.eviware.x.form.support.ADialogBuilder;
036:        import com.eviware.x.form.support.AField;
037:        import com.eviware.x.form.support.AForm;
038:        import com.eviware.x.form.support.AField.AFieldType;
039:
040:        /**
041:         * Updates the definition of a WsdlInterface.
042:         * 
043:         * @author Ole.Matzura
044:         */
045:
046:        public class UpdateInterfaceAction extends
047:                AbstractSoapUIAction<WsdlInterface> {
048:            public static final String SOAPUI_ACTION_ID = "UpdateInterfaceAction";
049:            private XFormDialog dialog = null;
050:
051:            public UpdateInterfaceAction() {
052:                super ("Update Definition",
053:                        "Reloads the definition for this interface and its operations");
054:            }
055:
056:            public void perform(WsdlInterface iface, Object param) {
057:                if (RemoveInterfaceAction.hasRunningDependingTests(iface)) {
058:                    UISupport
059:                            .showErrorMessage("Cannot update Interface due to running depending tests");
060:                    return;
061:                }
062:
063:                if (dialog == null) {
064:                    dialog = ADialogBuilder.buildDialog(Form.class);
065:                    dialog.setBooleanValue(Form.CREATE_REQUESTS, true);
066:                    dialog.getFormField(Form.CREATE_BACKUPS).setEnabled(false);
067:                    dialog.getFormField(Form.RECREATE_OPTIONAL).setEnabled(
068:                            false);
069:                    dialog.getFormField(Form.RECREATE_REQUESTS)
070:                            .addFormFieldListener(new XFormFieldListener() {
071:
072:                                public void valueChanged(
073:                                        XFormField sourceField,
074:                                        String newValue, String oldValue) {
075:                                    boolean enabled = dialog
076:                                            .getBooleanValue(Form.RECREATE_REQUESTS);
077:
078:                                    dialog.getFormField(Form.CREATE_BACKUPS)
079:                                            .setEnabled(enabled);
080:                                    dialog.getFormField(Form.RECREATE_OPTIONAL)
081:                                            .setEnabled(enabled);
082:                                }
083:                            });
084:                }
085:
086:                dialog.setValue(Form.DEFINITION_URL, iface.getDefinition());
087:                if (!dialog.show())
088:                    return;
089:
090:                String url = dialog.getValue(Form.DEFINITION_URL);
091:                if (url == null || url.trim().length() == 0)
092:                    return;
093:
094:                try {
095:                    File file = new File(url);
096:                    if (file.exists())
097:                        url = file.toURL().toString();
098:                } catch (Exception e) {
099:                    SoapUI.logError(e);
100:                }
101:
102:                boolean createRequests = dialog
103:                        .getBooleanValue(Form.CREATE_REQUESTS);
104:
105:                try {
106:                    if (iface.updateDefinition(url, createRequests)) {
107:                        if (dialog.getBooleanValue(Form.RECREATE_REQUESTS)) {
108:                            int cnt = recreateRequests(iface, dialog
109:                                    .getBooleanValue(Form.RECREATE_OPTIONAL),
110:                                    dialog.getBooleanValue(Form.CREATE_BACKUPS));
111:
112:                            UISupport.showInfoMessage(
113:                                    "Update of interface successfull, [" + cnt
114:                                            + "] requests have"
115:                                            + " been udpated.",
116:                                    "Update Definition");
117:                        } else {
118:                            UISupport.showInfoMessage(
119:                                    "Update of interface successfull",
120:                                    "Update Definition");
121:                        }
122:                    } else
123:                        UISupport.showInfoMessage("Update of interface failed",
124:                                "Update Definition");
125:                } catch (Exception e1) {
126:                    UISupport.showInfoMessage("Failed to update interface: ["
127:                            + e1 + "]", "Update Definition");
128:                    SoapUI.logError(e1);
129:                }
130:            }
131:
132:            protected int recreateRequests(WsdlInterface iface,
133:                    boolean buildOptional, boolean createBackups) {
134:                int count = 0;
135:
136:                // first check operations
137:                for (int c = 0; c < iface.getOperationCount(); c++) {
138:                    WsdlOperation operation = iface.getOperationAt(c);
139:                    String newRequest = operation.createRequest(buildOptional);
140:                    List<Request> requests = operation.getRequests();
141:
142:                    for (Request request : requests) {
143:                        String requestContent = request.getRequestContent();
144:                        String req = XmlUtils.transferValues(requestContent,
145:                                newRequest);
146:
147:                        // changed?
148:                        if (!req.equals(requestContent)) {
149:                            if (!XmlUtils.prettyPrintXml(req).equals(
150:                                    XmlUtils.prettyPrintXml(requestContent))) {
151:                                if (createBackups) {
152:                                    WsdlRequest backupRequest = operation
153:                                            .addNewRequest("Backup of ["
154:                                                    + request.getName() + "]");
155:                                    ((WsdlRequest) request).copyTo(
156:                                            backupRequest, false, false);
157:                                }
158:
159:                                ((WsdlRequest) request).setRequestContent(req);
160:                                count++;
161:                            }
162:                        }
163:                    }
164:                }
165:
166:                // now check testsuites..
167:                for (TestSuite testSuite : iface.getProject().getTestSuites()) {
168:                    for (TestCase testCase : testSuite.getTestCaseList()) {
169:                        for (int c = 0; c < testCase.getTestStepCount(); c++) {
170:                            WsdlTestStep testStep = (WsdlTestStep) testCase
171:                                    .getTestStepAt(c);
172:                            if (testStep instanceof  WsdlTestRequestStep) {
173:                                WsdlTestRequest testRequest = ((WsdlTestRequestStep) testStep)
174:                                        .getTestRequest();
175:                                String newRequest = testRequest.getOperation()
176:                                        .createRequest(buildOptional);
177:
178:                                String req = XmlUtils.transferValues(
179:                                        testRequest.getRequestContent(),
180:                                        newRequest);
181:
182:                                // changed?
183:                                if (!req
184:                                        .equals(testRequest.getRequestContent())) {
185:                                    if (createBackups) {
186:                                        ((WsdlTestCase) testCase)
187:                                                .importTestStep(
188:                                                        testStep,
189:                                                        "Backup of ["
190:                                                                + testStep
191:                                                                        .getName()
192:                                                                + "]", -1)
193:                                                .setDisabled(true);
194:                                    }
195:
196:                                    ((WsdlRequest) testRequest)
197:                                            .setRequestContent(req);
198:                                    count++;
199:                                }
200:                            }
201:                        }
202:                    }
203:                }
204:
205:                return count;
206:            }
207:
208:            @AForm(description="Specify Update Definition options",name="Update Definition")
209:            protected interface Form {
210:                @AField(name="Definition URL",description="The URL or file for the updated definition",type=AFieldType.FILE)
211:                public final static String DEFINITION_URL = "Definition URL";
212:
213:                @AField(name="Create New Requests",description="Create default requests for new methods",type=AFieldType.BOOLEAN)
214:                public final static String CREATE_REQUESTS = "Create New Requests";
215:
216:                @AField(name="Recreate Requests",description="Recreate existing request with the new schema",type=AFieldType.BOOLEAN)
217:                public final static String RECREATE_REQUESTS = "Recreate Requests";
218:
219:                @AField(name="Recreate Optional",description="Recreate optional content when updating requests",type=AFieldType.BOOLEAN)
220:                public final static String RECREATE_OPTIONAL = "Recreate Optional";
221:
222:                @AField(name="Create Backups",description="Create backup copies of changed requests",type=AFieldType.BOOLEAN)
223:                public final static String CREATE_BACKUPS = "Create Backups";
224:            }
225:        }
ww___w_.__j_a__va_2___s.c__o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.