Source Code Cross Referenced for PSServiceImpl.java in  » UML » MetaBoss » com » metaboss » sdlctools » domains » enterprisemodel » storage » xmlfileimpl » 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 » UML » MetaBoss » com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl;
016:
017:        import java.util.Iterator;
018:
019:        import javax.xml.bind.JAXBException;
020:
021:        import com.metaboss.enterprise.ps.PSDataSourceOperationInvocationException;
022:        import com.metaboss.enterprise.ps.PSException;
023:        import com.metaboss.enterprise.ps.PSIllegalArgumentException;
024:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSService;
025:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STConstraint;
026:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STField;
027:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STOperation;
028:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STOutputMessage;
029:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STService;
030:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.STServiceimplementation;
031:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ConstraintDefListType;
032:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ConstraintDefType;
033:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.FieldDefType;
034:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.InputFieldDefListType;
035:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OperationDefListType;
036:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OperationDefType;
037:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OutputFieldDefListType;
038:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OutputMessageDefListType;
039:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.OutputMessageDefType;
040:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ServiceDefType;
041:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ServiceimplementationDefListType;
042:        import com.metaboss.sdlctools.domains.enterprisemodel.storage.xmlfileimpl.dom.ServiceimplementationDefType;
043:        import com.metaboss.sdlctools.types.enterprisemodel.TransactionPolicyTextHelper;
044:        import com.metaboss.sdlctools.types.enterprisemodel.ZipArchive;
045:
046:        public class PSServiceImpl implements  PSService {
047:            /** Returns  details entity corresponding to given reference or null struct if definition not found */
048:            public STService getService(String pServiceRef) throws PSException {
049:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
050:                if (lServiceDef == null)
051:                    return null;
052:                STService lStruct = new STService();
053:                lStruct.ServiceRef = lServiceDef.getServiceRef();
054:                lStruct.Description = lServiceDef.getDescription();
055:                return lStruct;
056:            }
057:
058:            /** Inserts new service record into the database */
059:            public void insertService(STService pRecord) throws PSException {
060:                try {
061:                    ServiceDefType lServiceDef = Util.getObjectFactory()
062:                            .createServiceDef();
063:                    lServiceDef.setServiceRef(pRecord.ServiceRef);
064:                    lServiceDef.setDescription(pRecord.Description);
065:                    OperationDefListType lOperationDefList = Util
066:                            .getObjectFactory().createOperationDefList();
067:                    lServiceDef.setOperationDefList(lOperationDefList);
068:                    ServiceimplementationDefListType lServiceimplementationDefList = Util
069:                            .getObjectFactory()
070:                            .createServiceimplementationDefList();
071:                    lServiceDef
072:                            .setServiceimplementationDefList(lServiceimplementationDefList);
073:                    Storage.insertService(lServiceDef);
074:                } catch (JAXBException e) {
075:                    throw new PSDataSourceOperationInvocationException(e);
076:                }
077:            }
078:
079:            /* Returns single operation with the specified name from specified service */
080:            public STOperation getOperation(String pServiceRef,
081:                    String pOperationName) throws PSException {
082:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
083:                if (lServiceDef == null)
084:                    return null;
085:                OperationDefListType lOperationDefList = lServiceDef
086:                        .getOperationDefList();
087:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
088:                for (int i = 0; lIter.hasNext(); i++) {
089:                    OperationDefType lOperationDef = (OperationDefType) lIter
090:                            .next();
091:                    if (lOperationDef.getName().equals(pOperationName))
092:                        return convertOperationDef(pServiceRef, lOperationDef);
093:                }
094:                return null;
095:            }
096:
097:            /* Returns single operation with the specified name from specified service */
098:            public STOperation getOperation(String pOperationRef)
099:                    throws PSException {
100:                int lLastDot = pOperationRef.lastIndexOf('.');
101:                String lServiceRef = pOperationRef.substring(0, lLastDot);
102:                String lOperationName = pOperationRef.substring(lLastDot + 1);
103:                return getOperation(lServiceRef, lOperationName);
104:            }
105:
106:            /** Returns single service implementation details with the specified name from specified service */
107:            public STServiceimplementation getImplementation(
108:                    String pServiceRef, String pServiceimplementationRef)
109:                    throws PSException {
110:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
111:                if (lServiceDef == null)
112:                    return null;
113:                String lImplementationName = pServiceimplementationRef
114:                        .substring(pServiceimplementationRef.lastIndexOf(".") + 1);
115:                ServiceimplementationDefListType lServiceimplementationDefList = lServiceDef
116:                        .getServiceimplementationDefList();
117:                Iterator lIter = lServiceimplementationDefList
118:                        .getServiceimplementationDef().iterator();
119:                for (int i = 0; lIter.hasNext(); i++) {
120:                    ServiceimplementationDefType lServiceimplementationDef = (ServiceimplementationDefType) lIter
121:                            .next();
122:                    if (lServiceimplementationDef.getName().equals(
123:                            lImplementationName))
124:                        return convertFromServiceimplementationDef(pServiceRef,
125:                                lServiceimplementationDef);
126:                }
127:                return null;
128:            }
129:
130:            /* Returns all operations comprising service */
131:            public STServiceimplementation[] getImplementations(
132:                    String pServiceRef) throws PSException {
133:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
134:                if (lServiceDef == null)
135:                    return null;
136:                ServiceimplementationDefListType lServiceimplementationDefList = lServiceDef
137:                        .getServiceimplementationDefList();
138:                STServiceimplementation[] lReturn = new STServiceimplementation[lServiceimplementationDefList
139:                        .getServiceimplementationDef().size()];
140:                Iterator lIter = lServiceimplementationDefList
141:                        .getServiceimplementationDef().iterator();
142:                for (int i = 0; lIter.hasNext(); i++) {
143:                    lReturn[i] = convertFromServiceimplementationDef(
144:                            pServiceRef, (ServiceimplementationDefType) lIter
145:                                    .next());
146:                }
147:                return lReturn;
148:            }
149:
150:            /* Returns all operations comprising service */
151:            public STOperation[] getOperations(String pServiceRef)
152:                    throws PSException {
153:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
154:                if (lServiceDef == null)
155:                    return null;
156:                OperationDefListType lOperationDefList = lServiceDef
157:                        .getOperationDefList();
158:                STOperation[] lReturn = new STOperation[lOperationDefList
159:                        .getOperationDef().size()];
160:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
161:                for (int i = 0; lIter.hasNext(); i++) {
162:                    lReturn[i] = convertOperationDef(pServiceRef,
163:                            (OperationDefType) lIter.next());
164:                }
165:                return lReturn;
166:            }
167:
168:            /* Returns list of input fields for the operation with the specified name from specified service */
169:            public STField[] getInputFields(String pServiceRef,
170:                    String pOperationName) throws PSException {
171:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
172:                if (lServiceDef == null)
173:                    return null;
174:                OperationDefListType lOperationDefList = lServiceDef
175:                        .getOperationDefList();
176:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
177:                for (int i = 0; lIter.hasNext(); i++) {
178:                    OperationDefType lOperationDef = (OperationDefType) lIter
179:                            .next();
180:                    if (lOperationDef.getName().equals(pOperationName)) {
181:                        InputFieldDefListType lInputFieldDefList = lOperationDef
182:                                .getInputFieldDefList();
183:                        STField[] lReturn = new STField[lInputFieldDefList
184:                                .getFieldDef().size()];
185:                        Iterator lIter1 = lInputFieldDefList.getFieldDef()
186:                                .iterator();
187:                        for (int j = 0; lIter1.hasNext(); j++) {
188:                            lReturn[j] = Util.getField((FieldDefType) lIter1
189:                                    .next());
190:                        }
191:                        return lReturn;
192:                    }
193:                }
194:                return null;
195:            }
196:
197:            /* Returns list of input Constraints for the operation with the specified name from specified service */
198:            public STConstraint[] getInputConstraints(String pServiceRef,
199:                    String pOperationName) throws PSException {
200:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
201:                if (lServiceDef == null)
202:                    throw new PSException("Service not found. ServiceRef : "
203:                            + pServiceRef);
204:                OperationDefListType lOperationDefList = lServiceDef
205:                        .getOperationDefList();
206:                if (lOperationDefList != null
207:                        && lOperationDefList.getOperationDef() != null) {
208:                    Iterator lIter = lOperationDefList.getOperationDef()
209:                            .iterator();
210:                    for (int i = 0; lIter.hasNext(); i++) {
211:                        OperationDefType lOperationDef = (OperationDefType) lIter
212:                                .next();
213:                        if (lOperationDef.getName().equals(pOperationName)) {
214:                            ConstraintDefListType lInputConstraintDefList = lOperationDef
215:                                    .getConstraintDefList();
216:                            if (lInputConstraintDefList != null
217:                                    && lInputConstraintDefList
218:                                            .getConstraintDef() != null) {
219:                                STConstraint[] lReturn = new STConstraint[lInputConstraintDefList
220:                                        .getConstraintDef().size()];
221:                                Iterator lIter1 = lInputConstraintDefList
222:                                        .getConstraintDef().iterator();
223:                                for (int j = 0; lIter1.hasNext(); j++) {
224:                                    lReturn[j] = Util
225:                                            .getConstraint((ConstraintDefType) lIter1
226:                                                    .next());
227:                                }
228:                                return lReturn;
229:                            }
230:
231:                        }
232:                    }
233:                }
234:                return null;
235:            }
236:
237:            /* Returns list of output fields for the operation with the specified name from specified service */
238:            public STField[] getOutputFields(String pServiceRef,
239:                    String pOperationName) throws PSException {
240:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
241:                if (lServiceDef == null)
242:                    return null;
243:                OperationDefListType lOperationDefList = lServiceDef
244:                        .getOperationDefList();
245:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
246:                for (int i = 0; lIter.hasNext(); i++) {
247:                    OperationDefType lOperationDef = (OperationDefType) lIter
248:                            .next();
249:                    if (lOperationDef.getName().equals(pOperationName)) {
250:                        OutputFieldDefListType lOutputFieldDefList = lOperationDef
251:                                .getOutputFieldDefList();
252:                        STField[] lReturn = new STField[lOutputFieldDefList
253:                                .getFieldDef().size()];
254:                        Iterator lIter1 = lOutputFieldDefList.getFieldDef()
255:                                .iterator();
256:                        for (int j = 0; lIter1.hasNext(); j++) {
257:                            lReturn[j] = Util.getField((FieldDefType) lIter1
258:                                    .next());
259:                        }
260:                        return lReturn;
261:                    }
262:                }
263:                return null;
264:            }
265:
266:            /* Returns list of output messages for the operation */
267:            public STOutputMessage[] getOutputMessages(String pServiceRef,
268:                    String pOperationName) throws PSException {
269:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
270:                if (lServiceDef == null)
271:                    return null;
272:                OperationDefListType lOperationDefList = lServiceDef
273:                        .getOperationDefList();
274:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
275:                for (int i = 0; lIter.hasNext(); i++) {
276:                    OperationDefType lOperationDef = (OperationDefType) lIter
277:                            .next();
278:                    if (lOperationDef.getName().equals(pOperationName)) {
279:                        OutputMessageDefListType lOutputMessageDefList = lOperationDef
280:                                .getOutputMessageDefList();
281:                        STOutputMessage[] lReturn = new STOutputMessage[lOutputMessageDefList
282:                                .getOutputMessageDef().size()];
283:                        Iterator lIter1 = lOutputMessageDefList
284:                                .getOutputMessageDef().iterator();
285:                        for (int j = 0; lIter1.hasNext(); j++) {
286:                            lReturn[j] = Util
287:                                    .getOutputMessage((OutputMessageDefType) lIter1
288:                                            .next());
289:                        }
290:                        return lReturn;
291:                    }
292:                }
293:                return null;
294:            }
295:
296:            /** inserts operation into the service */
297:            public void insertOperation(String pServiceRef,
298:                    STOperation pNewOperation) throws PSException {
299:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
300:                if (lServiceDef == null)
301:                    throw new PSException("Service not found. ServiceRef : "
302:                            + pServiceRef);
303:                // Make sure that operation with the specified name does not exists yet
304:                OperationDefListType lOperationDefList = lServiceDef
305:                        .getOperationDefList();
306:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
307:                while (lIter.hasNext()) {
308:                    OperationDefType lOperationDef = (OperationDefType) lIter
309:                            .next();
310:                    if (lOperationDef.getName().equals(pNewOperation.Name))
311:                        throw new PSException(
312:                                "Attempt to insert duplicate operation. ServiceRef : "
313:                                        + pServiceRef + ". OperationName : "
314:                                        + pNewOperation.Name);
315:                }
316:                OperationDefType lNewOperationDef = Util
317:                        .getOperationDef(pNewOperation);
318:                lOperationDefList.getOperationDef().add(lNewOperationDef);
319:                Storage.updateService(lServiceDef);
320:            }
321:
322:            /** inserts implementation into the service */
323:            public void insertImplementation(String pServiceRef,
324:                    STServiceimplementation pNewImplementation)
325:                    throws PSException {
326:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
327:                if (lServiceDef == null)
328:                    throw new PSException("Service not found. ServiceRef : "
329:                            + pServiceRef);
330:                // Make sure that the implementation with the specified name does not exists yet
331:                ServiceimplementationDefListType lServiceimplementationDefList = lServiceDef
332:                        .getServiceimplementationDefList();
333:                String lImplementationName = pNewImplementation.ServiceimplementationRef
334:                        .substring(pNewImplementation.ServiceimplementationRef
335:                                .lastIndexOf(".") + 1);
336:                Iterator lIter = lServiceimplementationDefList
337:                        .getServiceimplementationDef().iterator();
338:                while (lIter.hasNext()) {
339:                    ServiceimplementationDefType lServiceimplementationDef = (ServiceimplementationDefType) lIter
340:                            .next();
341:                    if (lServiceimplementationDef.getName().equals(
342:                            lImplementationName))
343:                        throw new PSException(
344:                                "Attempt to insert duplicate implementation. ServiceRef : "
345:                                        + pServiceRef
346:                                        + ". ImplementationName : "
347:                                        + lImplementationName);
348:                }
349:                ServiceimplementationDefType lNewServiceimplementationDef = Util
350:                        .getServiceimplementationDef(pNewImplementation);
351:                lServiceimplementationDefList.getServiceimplementationDef()
352:                        .add(lNewServiceimplementationDef);
353:                Storage.updateService(lServiceDef);
354:            }
355:
356:            /** updates implementation into the service */
357:            public void updateImplementation(String pServiceRef,
358:                    STServiceimplementation pUpdatedImplementation)
359:                    throws PSException {
360:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
361:                if (lServiceDef == null)
362:                    throw new PSException("Service not found. ServiceRef : "
363:                            + pServiceRef);
364:                // Find existing implementation
365:                ServiceimplementationDefListType lServiceimplementationDefList = lServiceDef
366:                        .getServiceimplementationDefList();
367:                String lImplementationName = pUpdatedImplementation.ServiceimplementationRef
368:                        .substring(pUpdatedImplementation.ServiceimplementationRef
369:                                .lastIndexOf(".") + 1);
370:                Iterator lIter = lServiceimplementationDefList
371:                        .getServiceimplementationDef().iterator();
372:                for (int i = 0; lIter.hasNext(); i++) {
373:                    ServiceimplementationDefType lServiceimplementationDef = (ServiceimplementationDefType) lIter
374:                            .next();
375:                    if (lServiceimplementationDef.getName().equals(
376:                            lImplementationName)) {
377:                        lServiceimplementationDefList
378:                                .getServiceimplementationDef().remove(
379:                                        lServiceimplementationDef);
380:                        lServiceimplementationDefList
381:                                .getServiceimplementationDef()
382:                                .add(
383:                                        i,
384:                                        convertToServiceimplementationDef(pUpdatedImplementation));
385:                        Storage.updateService(lServiceDef);
386:                        return;
387:                    }
388:                }
389:                throw new PSException(
390:                        "Attempt to update non-existant implementation. ServiceRef : "
391:                                + pServiceRef + ". ImplementationName : "
392:                                + lImplementationName);
393:            }
394:
395:            /** inserts input field into the operation inside the service */
396:            public void insertInputField(String pServiceRef,
397:                    String pOperationName, STField pNewField)
398:                    throws PSException {
399:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
400:                if (lServiceDef == null)
401:                    throw new PSIllegalArgumentException(
402:                            "Service not found. ServiceRef: " + pServiceRef);
403:                // Find operation
404:                OperationDefListType lOperationDefList = lServiceDef
405:                        .getOperationDefList();
406:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
407:                while (lIter.hasNext()) {
408:                    OperationDefType lOperationDef = (OperationDefType) lIter
409:                            .next();
410:                    if (lOperationDef.getName().equals(pOperationName)) {
411:                        // Found operation. Make sure that the field does not exists
412:                        InputFieldDefListType lFieldDefList = lOperationDef
413:                                .getInputFieldDefList();
414:                        Iterator lFieldIter = lFieldDefList.getFieldDef()
415:                                .iterator();
416:                        while (lFieldIter.hasNext()) {
417:                            FieldDefType lFieldDef = (FieldDefType) lFieldIter
418:                                    .next();
419:                            if (lFieldDef.getName().equals(pNewField.Name))
420:                                throw new PSIllegalArgumentException(
421:                                        "Attempt to insert duplicate input field into the operation. ServiceRef : "
422:                                                + pServiceRef
423:                                                + ". OperationName : "
424:                                                + pOperationName
425:                                                + ". FieldName : "
426:                                                + pNewField.Name);
427:                        }
428:                        FieldDefType lNewFieldDef = Util.getFieldDef(pNewField);
429:                        lFieldDefList.getFieldDef().add(lNewFieldDef);
430:                        Storage.updateService(lServiceDef);
431:                        return;
432:                    }
433:                }
434:                throw new PSIllegalArgumentException(
435:                        "Operation not found. ServiceRef: " + pServiceRef
436:                                + ". OperationName: " + pOperationName);
437:            }
438:
439:            /** inserts output field into the operation inside the service */
440:            public void insertOutputField(String pServiceRef,
441:                    String pOperationName, STField pNewField)
442:                    throws PSException {
443:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
444:                if (lServiceDef == null)
445:                    throw new PSException("Service not found. ServiceRef : "
446:                            + pServiceRef);
447:                // Find operation
448:                OperationDefListType lOperationDefList = lServiceDef
449:                        .getOperationDefList();
450:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
451:                while (lIter.hasNext()) {
452:                    OperationDefType lOperationDef = (OperationDefType) lIter
453:                            .next();
454:                    if (lOperationDef.getName().equals(pOperationName)) {
455:                        // Found operation. Make sure that the field does not exists
456:                        OutputFieldDefListType lFieldDefList = lOperationDef
457:                                .getOutputFieldDefList();
458:                        Iterator lFieldIter = lFieldDefList.getFieldDef()
459:                                .iterator();
460:                        while (lFieldIter.hasNext()) {
461:                            FieldDefType lFieldDef = (FieldDefType) lFieldIter
462:                                    .next();
463:                            if (lFieldDef.getName().equals(pNewField.Name))
464:                                throw new PSException(
465:                                        "Attempt to insert duplicate output field into the operation. ServiceRef : "
466:                                                + pServiceRef
467:                                                + ". OperationName : "
468:                                                + pOperationName
469:                                                + ". FieldName : "
470:                                                + pNewField.Name);
471:                        }
472:                        FieldDefType lNewFieldDef = Util.getFieldDef(pNewField);
473:                        lFieldDefList.getFieldDef().add(lNewFieldDef);
474:                        Storage.updateService(lServiceDef);
475:                        return;
476:                    }
477:                }
478:                throw new PSException(
479:                        "Attempt to insert output field into non existant operation. ServiceRef : "
480:                                + pServiceRef + ". OperationName : "
481:                                + pOperationName);
482:            }
483:
484:            /* Inserts output message into the operation inside the service */
485:            public void insertOutputMessage(String pServiceRef,
486:                    String pOperationName, STOutputMessage pNewOutputMessage)
487:                    throws PSException {
488:                ServiceDefType lServiceDef = Storage.getService(pServiceRef);
489:                if (lServiceDef == null)
490:                    throw new PSException("Service not found. ServiceRef: "
491:                            + pServiceRef);
492:                // Find operation
493:                OperationDefListType lOperationDefList = lServiceDef
494:                        .getOperationDefList();
495:                Iterator lIter = lOperationDefList.getOperationDef().iterator();
496:                while (lIter.hasNext()) {
497:                    OperationDefType lOperationDef = (OperationDefType) lIter
498:                            .next();
499:                    if (lOperationDef.getName().equals(pOperationName)) {
500:                        // Found operation. Make sure that the message field does not exists
501:                        OutputMessageDefListType lOutputMessageDefList = lOperationDef
502:                                .getOutputMessageDefList();
503:                        Iterator lMessageFieldIter = lOutputMessageDefList
504:                                .getOutputMessageDef().iterator();
505:                        while (lMessageFieldIter.hasNext()) {
506:                            OutputMessageDefType lMessageFieldDef = (OutputMessageDefType) lMessageFieldIter
507:                                    .next();
508:                            if (lMessageFieldDef.getMessageRef().equals(
509:                                    pNewOutputMessage.MessageRef))
510:                                throw new PSException(
511:                                        "Attempt to insert duplicate output message field into the operation. ServiceRef: "
512:                                                + pServiceRef
513:                                                + ". OperationName: "
514:                                                + pOperationName
515:                                                + ". MessageRef: "
516:                                                + pNewOutputMessage.MessageRef);
517:                        }
518:                        OutputMessageDefType lNewMessageFieldDef = Util
519:                                .getMessageFieldDef(pNewOutputMessage);
520:                        lOutputMessageDefList.getOutputMessageDef().add(
521:                                lNewMessageFieldDef);
522:                        Storage.updateService(lServiceDef);
523:                        return;
524:                    }
525:                }
526:                throw new PSException(
527:                        "Attempt to insert output message into non existant operation. ServiceRef : "
528:                                + pServiceRef + ". OperationName : "
529:                                + pOperationName);
530:            }
531:
532:            /** Retireves implementation source archive for the specified service */
533:            public ZipArchive getImplementationSource(String pServiceRef,
534:                    String pServiceimplementationRef) throws PSException {
535:                if (!pServiceimplementationRef.startsWith(pServiceRef + "."))
536:                    throw new com.metaboss.enterprise.ps.PSIllegalArgumentException(
537:                            "ServiceimplementationRef and ServiceRef mismatch. ServiceRef : "
538:                                    + pServiceRef
539:                                    + " ServiceimplementationRef : "
540:                                    + pServiceimplementationRef);
541:                String lImplementationName = pServiceimplementationRef
542:                        .substring(pServiceimplementationRef.lastIndexOf(".") + 1);
543:                // Delegate work to storage
544:                return Storage.getServiceImplementationSource(pServiceRef,
545:                        lImplementationName);
546:            }
547:
548:            /** Saves implementation source for the specified service implementation */
549:            public void updateImplementationSource(String pServiceRef,
550:                    ZipArchive pSourceArchive) throws PSException {
551:                String lServiceimplementationRef = pServiceRef + "."
552:                        + pSourceArchive.getName();
553:                STServiceimplementation lDetailsStruct = getImplementation(
554:                        pServiceRef, lServiceimplementationRef);
555:                if (lDetailsStruct == null)
556:                    throw new com.metaboss.enterprise.ps.PSIllegalArgumentException(
557:                            "SourceArchive does not correspond to any implementation defined for the Service. ServiceRef : "
558:                                    + pServiceRef
559:                                    + " SourceArchiveName : "
560:                                    + pSourceArchive.getName());
561:                // Delegate work to storage
562:                Storage.updateServiceImplementationSource(pServiceRef,
563:                        pSourceArchive);
564:            }
565:
566:            // Helper. Converts xml struct to the PS struct
567:            private STOperation convertOperationDef(String pServiceRef,
568:                    OperationDefType pOperationDef) throws PSException {
569:                if (pOperationDef == null)
570:                    return null;
571:                STOperation lStruct = new STOperation();
572:                lStruct.Name = pOperationDef.getName();
573:                lStruct.ServiceRef = pServiceRef;
574:                lStruct.Description = pOperationDef.getDescription();
575:                lStruct.TransactionPolicy = TransactionPolicyTextHelper
576:                        .fromTextObject(pOperationDef
577:                                .getOperationTransactionPolicy());
578:                lStruct.IsQuery = pOperationDef.isOperationIsQuery();
579:                return lStruct;
580:            }
581:
582:            // Helper. Converts xml struct to the PS struct
583:            private STServiceimplementation convertFromServiceimplementationDef(
584:                    String pServiceRef,
585:                    ServiceimplementationDefType pServiceimplementationDef)
586:                    throws PSException {
587:                if (pServiceimplementationDef == null)
588:                    return null;
589:                STServiceimplementation lStruct = new STServiceimplementation();
590:                lStruct.ServiceimplementationRef = pServiceRef + "."
591:                        + pServiceimplementationDef.getName();
592:                lStruct.Description = pServiceimplementationDef
593:                        .getDescription();
594:                return lStruct;
595:            }
596:
597:            // Helper. Converts PS struct to the xml struct
598:            private ServiceimplementationDefType convertToServiceimplementationDef(
599:                    STServiceimplementation pServiceimplementationStruct)
600:                    throws PSException {
601:                try {
602:                    if (pServiceimplementationStruct == null)
603:                        return null;
604:                    ServiceimplementationDefType lDef = Util.getObjectFactory()
605:                            .createServiceimplementationDef();
606:                    lDef
607:                            .setName(pServiceimplementationStruct.ServiceimplementationRef
608:                                    .substring(pServiceimplementationStruct.ServiceimplementationRef
609:                                            .lastIndexOf(".") + 1));
610:                    lDef
611:                            .setDescription(pServiceimplementationStruct.Description);
612:                    return lDef;
613:                } catch (JAXBException e) {
614:                    throw new PSDataSourceOperationInvocationException(e);
615:                }
616:            }
617:        }
w__ww_._j___a__va2__s_.___c__om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.