Source Code Cross Referenced for MediaEntityLocalTestDriverBean.java in  » J2EE » JOnAS-4.8.6 » com » ibm » emb » meb » test » ejb » 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 » J2EE » JOnAS 4.8.6 » com.ibm.emb.meb.test.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.ibm.emb.meb.test.ejb;
002:
003:        import java.io.File;
004:        import java.io.FileInputStream;
005:        import java.io.FileNotFoundException;
006:        import java.io.IOException;
007:        import java.net.URL;
008:        import java.util.Arrays;
009:
010:        import javax.ejb.CreateException;
011:        import javax.ejb.EJBException;
012:        import javax.ejb.FinderException;
013:        import javax.ejb.RemoveException;
014:        import javax.emb.ContentAccessException;
015:        import javax.emb.ContentTooLargeException;
016:        import javax.emb.ContentUnmutableException;
017:        import javax.emb.ConversionException;
018:        import javax.emb.FormatFeatureException;
019:        import javax.emb.FormatNotFoundException;
020:        import javax.emb.FormatSyntaxException;
021:        import javax.emb.LinkTranslationException;
022:        import javax.emb.ListenerVetoException;
023:        import javax.emb.LocationUnmutableException;
024:        import javax.emb.MalformedLocationException;
025:        import javax.emb.Media;
026:        import javax.emb.MediaConverterSpec;
027:        import javax.emb.MediaEntityLocal;
028:        import javax.emb.MediaEntityLocalHome;
029:        import javax.emb.MediaException;
030:        import javax.emb.MediaFormat;
031:        import javax.emb.MediaFormatException;
032:        import javax.emb.MediaFormatRegistry;
033:        import javax.emb.MediaListener;
034:        import javax.emb.MetaDataEntityLocal;
035:        import javax.emb.MetaDataEntityLocalHome;
036:        import javax.emb.NoServerFoundException;
037:        import javax.emb.ProtocolConstraints;
038:        import javax.emb.VersionChainIntegrityException;
039:        import javax.naming.InitialContext;
040:        import javax.naming.NamingException;
041:
042:        import com.ibm.emb.meb.wrapper.MediaEntityWrapperBean;
043:
044:        /**
045:         * Bean implementation class for Enterprise Bean: MediaEntityLocalTestDriver
046:         */
047:        public class MediaEntityLocalTestDriverBean extends
048:                MediaEntityWrapperBean implements  javax.ejb.SessionBean {
049:
050:            /**
051:             *
052:             */
053:            private static final long serialVersionUID = 3258416140169719863L;
054:
055:            private static String MEBHOME_JNDI = "java:comp/env/ejb/emb/MediaEntityLocalHome";
056:
057:            private static String MDEBHOME_JNDI = "java:comp/env/ejb/emb/MetaDataEntityLocalHome";
058:
059:            private javax.ejb.SessionContext mySessionCtx;
060:
061:            private MediaEntityLocalHome meb_home;
062:
063:            private MetaDataEntityLocalHome mdeb_home;
064:
065:            private InitialContext ic;
066:
067:            /**
068:             * getSessionContext
069:             */
070:            public javax.ejb.SessionContext getSessionContext() {
071:                return mySessionCtx;
072:            }
073:
074:            /**
075:             * setSessionContext
076:             */
077:            public void setSessionContext(javax.ejb.SessionContext ctx) {
078:                mySessionCtx = ctx;
079:            }
080:
081:            /**
082:             * ejbCreate
083:             */
084:            public void ejbCreate() throws javax.ejb.CreateException {
085:            }
086:
087:            /**
088:             * ejbActivate
089:             */
090:            public void ejbActivate() {
091:            }
092:
093:            /**
094:             * ejbPassivate
095:             */
096:            public void ejbPassivate() {
097:            }
098:
099:            /**
100:             * ejbRemove
101:             */
102:            public void ejbRemove() {
103:            }
104:
105:            private InitialContext getInitialContext() throws NamingException {
106:                if (ic == null)
107:                    ic = new InitialContext();
108:                return ic;
109:            }
110:
111:            private MediaEntityLocalHome getMebHome() throws NamingException {
112:                if (meb_home == null)
113:                    meb_home = (MediaEntityLocalHome) getInitialContext()
114:                            .lookup(MEBHOME_JNDI);
115:                return meb_home;
116:            }
117:
118:            private MetaDataEntityLocalHome getMdebHome()
119:                    throws NamingException {
120:                if (mdeb_home == null)
121:                    mdeb_home = (MetaDataEntityLocalHome) getInitialContext()
122:                            .lookup(MDEBHOME_JNDI);
123:                return mdeb_home;
124:            }
125:
126:            public void cleanUp() throws NamingException {
127:
128:            }
129:
130:            private boolean checkEJBException(EJBException caughtException,
131:                    Class exceptionToCheck) {
132:                boolean flag = false;
133:
134:                EJBException tmp = (EJBException) caughtException;
135:                while (tmp.getCausedByException() != null) {
136:                    // System.out.println("[EXCEPTION] " +
137:                    // tmp.getCausedByException().getClass().getName());
138:                    if (tmp.getCausedByException().getClass() == exceptionToCheck) {
139:                        // System.out.println("[MATCH FOUND]");
140:                        flag = true;
141:                        break;
142:                    } else if (tmp.getCausedByException() instanceof  EJBException) {
143:                        tmp = (EJBException) tmp.getCausedByException();
144:                    } else {
145:                        break;
146:                    }
147:                }
148:                return flag;
149:            }
150:
151:            public void bindMediaFormat(String fileExt, MediaFormat format)
152:                    throws MediaException {
153:                MediaFormatRegistry reg = MediaFormatRegistry.SINGLETON;
154:                reg.rebind(fileExt, format);
155:            }
156:
157:            public void unbindMediaFormat(String fileExt) throws MediaException {
158:                MediaFormatRegistry reg = MediaFormatRegistry.SINGLETON;
159:                reg.unbind(fileExt);
160:            }
161:
162:            public MediaFormat lookUpMediaFormat(String fileExt)
163:                    throws MediaException {
164:                MediaFormatRegistry reg = MediaFormatRegistry.SINGLETON;
165:                return reg.lookup(fileExt);
166:            }
167:
168:            public int removeMEBExceptions(String pk) throws NamingException,
169:                    FinderException, RemoveException, ListenerVetoException {
170:                MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
171:                try {
172:                    meb.remove();
173:                } catch (EJBException e) {
174:                    if (checkEJBException(e, ListenerVetoException.class))
175:                        return MediaEntityLocalTestDriver.LISTENERVETO;
176:                    else
177:                        throw e;
178:                }
179:                return 0;
180:            }
181:
182:            public void removeMEBByPK(String pk) throws NamingException,
183:                    FinderException, RemoveException {
184:                MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
185:                meb.remove();
186:            }
187:
188:            public void removeMDEBByPK(String pk) throws NamingException,
189:                    FinderException, RemoveException {
190:                MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
191:                mdeb.remove();
192:            }
193:
194:            public int setContentExceptions(String pk, File file)
195:                    throws FileNotFoundException, NamingException,
196:                    FinderException, MediaException {
197:
198:                try {
199:                    setMediaEntityContent(pk, file);
200:                } catch (NullPointerException e) {
201:                    return MediaEntityLocalTestDriver.NULLPOINTER;
202:                } catch (ContentAccessException e) {
203:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
204:                } catch (FormatSyntaxException e) {
205:                    return MediaEntityLocalTestDriver.FORMATSYNTAX;
206:                } catch (ContentUnmutableException e) {
207:                    return MediaEntityLocalTestDriver.CONTENTUNMUTABLE;
208:                } catch (ContentTooLargeException e) {
209:                    return MediaEntityLocalTestDriver.CONTENTTOOLARGE;
210:                } catch (FormatNotFoundException e) {
211:                    return MediaEntityLocalTestDriver.FORMATNOTFOUND;
212:                } catch (ListenerVetoException e) {
213:                    return MediaEntityLocalTestDriver.LISTENERVETO;
214:                } catch (EJBException e) {
215:                    if (checkEJBException(e, NullPointerException.class)) {
216:                        return MediaEntityLocalTestDriver.NULLPOINTER;
217:                    } else if (checkEJBException(e, ListenerVetoException.class)) {
218:                        return MediaEntityLocalTestDriver.LISTENERVETO;
219:                    } else {
220:                        throw e;
221:                    }
222:                }
223:                return 0;
224:            }
225:
226:            public int setContentExceptions(String pk, byte[] content)
227:                    throws NamingException, FinderException, MediaException {
228:
229:                try {
230:                    setMediaEntityContent(pk, content);
231:                } catch (NullPointerException e) {
232:                    return MediaEntityLocalTestDriver.NULLPOINTER;
233:                } catch (ContentAccessException e) {
234:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
235:                } catch (FormatSyntaxException e) {
236:                    return MediaEntityLocalTestDriver.FORMATSYNTAX;
237:                } catch (ContentUnmutableException e) {
238:                    return MediaEntityLocalTestDriver.CONTENTUNMUTABLE;
239:                } catch (ContentTooLargeException e) {
240:                    return MediaEntityLocalTestDriver.CONTENTTOOLARGE;
241:                } catch (FormatNotFoundException e) {
242:                    return MediaEntityLocalTestDriver.FORMATNOTFOUND;
243:                } catch (ListenerVetoException e) {
244:                    return MediaEntityLocalTestDriver.LISTENERVETO;
245:                } catch (EJBException e) {
246:                    if (checkEJBException(e, NullPointerException.class)) {
247:                        return MediaEntityLocalTestDriver.NULLPOINTER;
248:                    } else if (checkEJBException(e, ListenerVetoException.class)) {
249:                        return MediaEntityLocalTestDriver.LISTENERVETO;
250:                    } else {
251:                        throw e;
252:                    }
253:                }
254:                return 0;
255:            }
256:
257:            public int addListenerExceptions(String pk, MediaListener listener)
258:                    throws MediaException, NamingException, FinderException {
259:                try {
260:                    addMediaEntityListener(pk, listener);
261:                } catch (NullPointerException e) {
262:                    return MediaEntityLocalTestDriver.NULLPOINTER;
263:                } catch (EJBException e) {
264:                    if (checkEJBException(e, NullPointerException.class)) {
265:                        return MediaEntityLocalTestDriver.NULLPOINTER;
266:                    } else {
267:                        throw e;
268:                    }
269:                }
270:                return 0;
271:            }
272:
273:            public int addMetaDataExceptions(String pk, String mdeb)
274:                    throws MediaException, NamingException, FinderException {
275:                try {
276:                    addMediaEntityMetaData(pk, mdeb);
277:                } catch (NullPointerException e) {
278:                    return MediaEntityLocalTestDriver.NULLPOINTER;
279:                } catch (EJBException e) {
280:                    if (checkEJBException(e, NullPointerException.class)) {
281:                        return MediaEntityLocalTestDriver.NULLPOINTER;
282:                    } else {
283:                        throw e;
284:                    }
285:                }
286:                return 0;
287:            }
288:
289:            public int convertExceptions(String pk, MediaConverterSpec[] specs)
290:                    throws MediaException, NamingException, FinderException {
291:                try {
292:                    convertMediaEntity(pk, specs);
293:                } catch (NullPointerException e) {
294:                    return MediaEntityLocalTestDriver.NULLPOINTER;
295:                } catch (ContentAccessException e) {
296:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
297:                } catch (ConversionException e) {
298:                    return MediaEntityLocalTestDriver.CONVERSION;
299:                } catch (MediaFormatException e) {
300:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
301:                } catch (ListenerVetoException e) {
302:                    return MediaEntityLocalTestDriver.LISTENERVETO;
303:                } catch (ContentUnmutableException e) {
304:                    return MediaEntityLocalTestDriver.CONTENTUNMUTABLE;
305:                } catch (EJBException e) {
306:                    if (checkEJBException(e, NullPointerException.class)) {
307:                        return MediaEntityLocalTestDriver.NULLPOINTER;
308:                    } else {
309:                        throw e;
310:                    }
311:                }
312:                return 0;
313:            }
314:
315:            public int exportMediaExceptions(String pk, URL targetLocation)
316:                    throws MediaException, NamingException, FinderException {
317:                try {
318:                    exportMediaEntity(pk, targetLocation);
319:                } catch (NullPointerException e) {
320:                    return MediaEntityLocalTestDriver.NULLPOINTER;
321:                } catch (ContentAccessException e) {
322:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
323:                } catch (MalformedLocationException e) {
324:                    return MediaEntityLocalTestDriver.MALFORMEDLOCATION;
325:                } catch (EJBException e) {
326:                    if (checkEJBException(e, NullPointerException.class)) {
327:                        return MediaEntityLocalTestDriver.NULLPOINTER;
328:                    } else {
329:                        throw e;
330:                    }
331:                }
332:                return 0;
333:            }
334:
335:            public int getContentExceptions(String pk) throws MediaException,
336:                    NamingException, FinderException {
337:                try {
338:                    getMediaEntityContent(pk);
339:                } catch (ContentAccessException e) {
340:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
341:                } catch (ContentTooLargeException e) {
342:                    return MediaEntityLocalTestDriver.CONTENTTOOLARGE;
343:                }
344:                return 0;
345:            }
346:
347:            public int getFormatExceptions(String pk) throws MediaException,
348:                    NamingException, FinderException {
349:                try {
350:                    getMediaEntityFormat(pk);
351:                } catch (FormatNotFoundException e) {
352:                    return MediaEntityLocalTestDriver.FORMATNOTFOUND;
353:                }
354:                return 0;
355:            }
356:
357:            public int getHeaderExceptions(String pk) throws MediaException,
358:                    NamingException, FinderException {
359:                try {
360:                    getMediaEntityHeader(pk);
361:                } catch (FormatNotFoundException e) {
362:                    return MediaEntityLocalTestDriver.FORMATNOTFOUND;
363:                } catch (FormatSyntaxException e) {
364:                    return MediaEntityLocalTestDriver.FORMATSYNTAX;
365:                } catch (FormatFeatureException e) {
366:                    return MediaEntityLocalTestDriver.FORMATFEATURE;
367:                }
368:                return 0;
369:            }
370:
371:            public int getMimeTypeExceptions(String pk) throws MediaException,
372:                    NamingException, FinderException {
373:                try {
374:                    getMediaEntityMimeType(pk);
375:                } catch (FormatNotFoundException e) {
376:                    return MediaEntityLocalTestDriver.FORMATNOTFOUND;
377:                }
378:                return 0;
379:            }
380:
381:            public int getProxyExceptions(String pk) throws MediaException,
382:                    NamingException, FinderException {
383:                try {
384:                    getMediaEntityProxy(pk);
385:                } catch (ContentAccessException e) {
386:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
387:                } catch (MediaFormatException e) {
388:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
389:                }
390:                return 0;
391:            }
392:
393:            public int getSizeExceptions(String pk) throws MediaException,
394:                    NamingException, FinderException {
395:                try {
396:                    getMediaEntitySize(pk);
397:                } catch (ContentAccessException e) {
398:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
399:                }
400:                return 0;
401:            }
402:
403:            public int importMediaExceptions(String pk, URL targetLocation,
404:                    String name) throws MediaException, NamingException,
405:                    FinderException {
406:                try {
407:                    importMediaEntityContent(pk, targetLocation, name);
408:                } catch (NullPointerException e) {
409:                    return MediaEntityLocalTestDriver.NULLPOINTER;
410:                } catch (ContentAccessException e) {
411:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
412:                } catch (ContentTooLargeException e) {
413:                    return MediaEntityLocalTestDriver.CONTENTTOOLARGE;
414:                } catch (MalformedLocationException e) {
415:                    return MediaEntityLocalTestDriver.MALFORMEDLOCATION;
416:                } catch (ListenerVetoException e) {
417:                    return MediaEntityLocalTestDriver.LISTENERVETO;
418:                } catch (EJBException e) {
419:                    if (checkEJBException(e, NullPointerException.class)) {
420:                        return MediaEntityLocalTestDriver.NULLPOINTER;
421:                    } else {
422:                        throw e;
423:                    }
424:                } catch (CreateException ce) {
425:                    return 0;
426:                }
427:                return 0;
428:            }
429:
430:            public boolean readCompareContent(String pk, long position,
431:                    byte[] buffer, File origFileContent) throws IOException,
432:                    NamingException, FinderException, MediaException {
433:                int amountCopied = this .readMediaEntityContent(pk, position,
434:                        buffer);
435:
436:                FileInputStream file1024ByteInputStream = new FileInputStream(
437:                        origFileContent);
438:                byte[] fileArray = new byte[amountCopied];
439:                file1024ByteInputStream.skip(position);
440:
441:                int amountRead = file1024ByteInputStream.read(fileArray, 0,
442:                        amountCopied);
443:                if (amountRead != amountCopied) {
444:                    System.out.println("amountRead: " + amountRead
445:                            + " amountCopied: " + amountCopied);
446:                    throw new ContentAccessException(
447:                            "error when extracting content from original file");
448:                }
449:                byte[] actualBuffer = null;
450:                if (amountRead < buffer.length) {
451:                    System.out.println("amountRead: " + amountRead);
452:                    actualBuffer = new byte[amountRead];
453:                    for (int i = 0; i < amountRead; i++) {
454:                        actualBuffer[i] = buffer[i];
455:                    }
456:                } else {
457:                    actualBuffer = buffer;
458:                }
459:                file1024ByteInputStream.close();
460:                if (java.util.Arrays.equals(fileArray, actualBuffer))
461:                    return true;
462:                else {
463:                    System.out.println("content does not match");
464:                    return false;
465:                }
466:            }
467:
468:            public int readContentExceptions(String pk, long position,
469:                    byte[] buffer) throws MediaException, NamingException,
470:                    FinderException {
471:                try {
472:                    readMediaEntityContent(pk, position, buffer);
473:                } catch (NullPointerException e) {
474:                    return MediaEntityLocalTestDriver.NULLPOINTER;
475:                } catch (ContentAccessException e) {
476:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
477:                } catch (IndexOutOfBoundsException e) {
478:                    return MediaEntityLocalTestDriver.INDEXOUTOFBOUNDS;
479:                } catch (EJBException e) {
480:                    if (checkEJBException(e, NullPointerException.class)) {
481:                        return MediaEntityLocalTestDriver.NULLPOINTER;
482:                    } else if (checkEJBException(e,
483:                            IndexOutOfBoundsException.class)) {
484:                        return MediaEntityLocalTestDriver.INDEXOUTOFBOUNDS;
485:                    } else if (checkEJBException(e,
486:                            NegativeArraySizeException.class)) {
487:                        return MediaEntityLocalTestDriver.NEGATIVEARRAYSIZE;
488:                    } else {
489:                        throw e;
490:                    }
491:                }
492:                return 0;
493:            }
494:
495:            public boolean readCompareContent(String pk, long position,
496:                    byte[] buffer, int offset, int length, byte[] origContent,
497:                    boolean fillBuffer) throws MediaException, NamingException,
498:                    FinderException {
499:                int totalCopied = 0;
500:                int amountCopied = 0;
501:
502:                amountCopied = this .readMediaEntityContent(pk, position,
503:                        buffer, offset, length);
504:                totalCopied = totalCopied + amountCopied;
505:                // if fillBuffer is true and the buffer did not get filled all the way,
506:                // loop until filled
507:                while (fillBuffer && (totalCopied != length)) {
508:                    amountCopied = this .readMediaEntityContent(pk, position
509:                            + totalCopied, buffer, offset + totalCopied, length
510:                            - totalCopied);
511:                    totalCopied = totalCopied + amountCopied;
512:                }
513:
514:                // compare against original content
515:                byte[] expBuffer = new byte[buffer.length];
516:                System.arraycopy(origContent, (int) position, expBuffer,
517:                        offset, amountCopied);
518:
519:                if (Arrays.equals(expBuffer, buffer))
520:                    return true;
521:                else {
522:                    System.out
523:                            .println("expected byte arrray and retrieved byte array are not equal");
524:                    return false;
525:                }
526:            }
527:
528:            public int readContentExceptions(String pk, long position,
529:                    byte[] buffer, int offset, int length)
530:                    throws MediaException, NamingException, FinderException {
531:                try {
532:                    readMediaEntityContent(pk, position, buffer, offset, length);
533:                } catch (NullPointerException e) {
534:                    return MediaEntityLocalTestDriver.NULLPOINTER;
535:                } catch (ContentAccessException e) {
536:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
537:                } catch (IndexOutOfBoundsException e) {
538:                    return MediaEntityLocalTestDriver.INDEXOUTOFBOUNDS;
539:                } catch (NegativeArraySizeException e) {
540:                    return MediaEntityLocalTestDriver.NEGATIVEARRAYSIZE;
541:                } catch (EJBException e) {
542:                    if (checkEJBException(e, NullPointerException.class)) {
543:                        return MediaEntityLocalTestDriver.NULLPOINTER;
544:                    } else if (checkEJBException(e,
545:                            IndexOutOfBoundsException.class)) {
546:                        return MediaEntityLocalTestDriver.INDEXOUTOFBOUNDS;
547:                    } else if (checkEJBException(e,
548:                            NegativeArraySizeException.class)) {
549:                        return MediaEntityLocalTestDriver.NEGATIVEARRAYSIZE;
550:                    } else {
551:                        throw e;
552:                    }
553:                }
554:                return 0;
555:            }
556:
557:            public int removeListenerExceptions(String pk,
558:                    MediaListener listener) throws MediaException,
559:                    NamingException, FinderException {
560:                try {
561:                    removeMediaEntityListener(pk, listener);
562:                } catch (NullPointerException e) {
563:                    return MediaEntityLocalTestDriver.NULLPOINTER;
564:                } catch (EJBException e) {
565:                    if (checkEJBException(e, NullPointerException.class)) {
566:                        return MediaEntityLocalTestDriver.NULLPOINTER;
567:                    } else {
568:                        throw e;
569:                    }
570:                }
571:                return 0;
572:            }
573:
574:            public int removeMetaDataExceptions(String pk, String mdeb)
575:                    throws MediaException, NamingException, FinderException {
576:                try {
577:                    removeMediaEntityMetaData(pk, mdeb);
578:                } catch (NullPointerException e) {
579:                    return MediaEntityLocalTestDriver.NULLPOINTER;
580:                } catch (EJBException e) {
581:                    if (checkEJBException(e, NullPointerException.class)) {
582:                        return MediaEntityLocalTestDriver.NULLPOINTER;
583:                    } else {
584:                        throw e;
585:                    }
586:                }
587:                return 0;
588:            }
589:
590:            public int setChildrenExceptions(String pk, String[] children)
591:                    throws MediaException, NamingException, FinderException {
592:                try {
593:                    setMediaEntityChildren(pk, children);
594:                } catch (NullPointerException e) {
595:                    return MediaEntityLocalTestDriver.NULLPOINTER;
596:                } catch (IllegalArgumentException e) {
597:                    return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
598:                } catch (ContentUnmutableException e) {
599:                    return MediaEntityLocalTestDriver.CONTENTUNMUTABLE;
600:                } catch (ContentAccessException e) {
601:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
602:                } catch (EJBException e) {
603:                    if (checkEJBException(e, NullPointerException.class)) {
604:                        return MediaEntityLocalTestDriver.NULLPOINTER;
605:                    } else if (checkEJBException(e,
606:                            IllegalArgumentException.class)) {
607:                        return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
608:                    } else {
609:                        throw e;
610:                    }
611:                }
612:                return 0;
613:            }
614:
615:            public int setDescriptionExceptions(String pk, String description)
616:                    throws MediaException, NamingException, FinderException {
617:                try {
618:                    setMediaEntityDescription(pk, description);
619:                } catch (ListenerVetoException e) {
620:                    return MediaEntityLocalTestDriver.LISTENERVETO;
621:                }
622:                return 0;
623:            }
624:
625:            public int setLocationExceptions(String pk, URL location)
626:                    throws MediaException, NamingException, FinderException {
627:                try {
628:                    setMediaEntityLocation(pk, location);
629:                } catch (ContentAccessException e) {
630:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
631:                } catch (LocationUnmutableException e) {
632:                    return MediaEntityLocalTestDriver.LOCATIONUNMUTABLE;
633:                } catch (ListenerVetoException e) {
634:                    return MediaEntityLocalTestDriver.LISTENERVETO;
635:                }
636:                return 0;
637:            }
638:
639:            public int setMimeTypeExceptions(String pk, String mimeType)
640:                    throws MediaException, NamingException, FinderException {
641:                try {
642:                    setMediaEntityMimeType(pk, mimeType);
643:                } catch (ListenerVetoException e) {
644:                    return MediaEntityLocalTestDriver.LISTENERVETO;
645:                }
646:                return 0;
647:            }
648:
649:            public int setNameExceptions(String pk, String name)
650:                    throws MediaException, NamingException, FinderException {
651:                try {
652:                    setMediaEntityName(pk, name);
653:                } catch (NullPointerException e) {
654:                    return MediaEntityLocalTestDriver.NULLPOINTER;
655:                } catch (IllegalArgumentException e) {
656:                    return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
657:                } catch (FormatNotFoundException e) {
658:                    return MediaEntityLocalTestDriver.FORMATNOTFOUND;
659:                } catch (ListenerVetoException e) {
660:                    return MediaEntityLocalTestDriver.LISTENERVETO;
661:                } catch (EJBException e) {
662:                    if (checkEJBException(e, NullPointerException.class)) {
663:                        return MediaEntityLocalTestDriver.NULLPOINTER;
664:                    } else if (checkEJBException(e,
665:                            IllegalArgumentException.class)) {
666:                        return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
667:                    } else {
668:                        throw e;
669:                    }
670:                }
671:                return 0;
672:            }
673:
674:            public int setPreviousVersionExceptions(String pk, String pvpk)
675:                    throws MediaException, NamingException, FinderException {
676:                try {
677:                    setMediaEntityPreviousVersion(pk, pvpk);
678:                } catch (VersionChainIntegrityException e) {
679:                    return MediaEntityLocalTestDriver.VERSIONCHAININTEGRITY;
680:                }
681:                return 0;
682:            }
683:
684:            public int exportHomeMediaExceptions(String[] pks, URL targetDir)
685:                    throws MediaException, NamingException, FinderException {
686:                try {
687:                    exportHomeMediaEntityBeans(pks, targetDir);
688:                } catch (NullPointerException e) {
689:                    return MediaEntityLocalTestDriver.NULLPOINTER;
690:                } catch (ContentAccessException e) {
691:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
692:                } catch (MediaFormatException e) {
693:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
694:                } catch (MalformedLocationException e) {
695:                    return MediaEntityLocalTestDriver.MALFORMEDLOCATION;
696:                } catch (EJBException e) {
697:                    if (checkEJBException(e, NullPointerException.class)) {
698:                        return MediaEntityLocalTestDriver.NULLPOINTER;
699:                    } else {
700:                        throw e;
701:                    }
702:                }
703:                return 0;
704:            }
705:
706:            public int findByPKExceptions(String pk) throws NamingException {
707:                try {
708:                    findMEBByPrimaryKey(pk);
709:                } catch (NullPointerException e) {
710:                    return MediaEntityLocalTestDriver.NULLPOINTER;
711:                } catch (FinderException e) {
712:                    return MediaEntityLocalTestDriver.FINDER;
713:                } catch (EJBException e) {
714:                    if (checkEJBException(e, NullPointerException.class)) {
715:                        return MediaEntityLocalTestDriver.NULLPOINTER;
716:                    } else {
717:                        throw e;
718:                    }
719:                }
720:                return 0;
721:            }
722:
723:            public int importHomeMediaExceptions(URL[] locations, String[] names)
724:                    throws CreateException, MediaException, NamingException,
725:                    FinderException {
726:                try {
727:                    importHomeMediaEntityBeans(locations, names);
728:                } catch (NullPointerException e) {
729:                    return MediaEntityLocalTestDriver.NULLPOINTER;
730:                } catch (ContentAccessException e) {
731:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
732:                } catch (ContentTooLargeException e) {
733:                    return MediaEntityLocalTestDriver.CONTENTTOOLARGE;
734:                } catch (MediaFormatException e) {
735:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
736:                } catch (MalformedLocationException e) {
737:                    return MediaEntityLocalTestDriver.MALFORMEDLOCATION;
738:                } catch (IllegalArgumentException e) {
739:                    return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
740:                } catch (ListenerVetoException e) {
741:                    return MediaEntityLocalTestDriver.LISTENERVETO;
742:                } catch (EJBException e) {
743:                    if (checkEJBException(e, NullPointerException.class)) {
744:                        return MediaEntityLocalTestDriver.NULLPOINTER;
745:                    } else if (checkEJBException(e,
746:                            IllegalArgumentException.class)) {
747:                        return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
748:                    } else {
749:                        throw e;
750:                    }
751:                }
752:                return 0;
753:            }
754:
755:            public int publishContentExceptions(Media content,
756:                    byte transferType, ProtocolConstraints constraints)
757:                    throws MediaException, NamingException, FinderException {
758:                try {
759:                    publishMediaContent(content, transferType, constraints);
760:                } catch (NullPointerException e) {
761:                    return MediaEntityLocalTestDriver.NULLPOINTER;
762:                } catch (ContentAccessException e) {
763:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
764:                } catch (MediaFormatException e) {
765:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
766:                } catch (NoServerFoundException e) {
767:                    return MediaEntityLocalTestDriver.NOSERVERFOUND;
768:                } catch (IllegalArgumentException e) {
769:                    return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
770:                } catch (ConversionException e) {
771:                    return MediaEntityLocalTestDriver.CONVERSION;
772:                } catch (LinkTranslationException e) {
773:                    return MediaEntityLocalTestDriver.LINKTRANSLATION;
774:                } catch (EJBException e) {
775:                    if (checkEJBException(e, NullPointerException.class)) {
776:                        return MediaEntityLocalTestDriver.NULLPOINTER;
777:                    } else if (checkEJBException(e,
778:                            IllegalArgumentException.class)) {
779:                        return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
780:                    } else {
781:                        throw e;
782:                    }
783:                }
784:                return 0;
785:            }
786:
787:            public URL publishMediaContent(String pk, byte protocol,
788:                    ProtocolConstraints constraints) throws MediaException,
789:                    NamingException, FinderException {
790:                if (pk == null)
791:                    throw new NullPointerException(
792:                            "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
793:                MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
794:                URL url = getMebHome().publishContent(meb, protocol,
795:                        constraints);
796:                return url;
797:            }
798:
799:            public int publishContentExceptions(String pk, byte transferType,
800:                    ProtocolConstraints constraints) throws MediaException,
801:                    NamingException, FinderException {
802:
803:                if (pk == null)
804:                    throw new NullPointerException(
805:                            "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
806:                MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
807:                try {
808:                    publishMediaContent(meb, transferType, constraints);
809:                } catch (NullPointerException e) {
810:                    return MediaEntityLocalTestDriver.NULLPOINTER;
811:                } catch (ContentAccessException e) {
812:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
813:                } catch (MediaFormatException e) {
814:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
815:                } catch (NoServerFoundException e) {
816:                    return MediaEntityLocalTestDriver.NOSERVERFOUND;
817:                } catch (IllegalArgumentException e) {
818:                    return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
819:                } catch (ConversionException e) {
820:                    return MediaEntityLocalTestDriver.CONVERSION;
821:                } catch (LinkTranslationException e) {
822:                    return MediaEntityLocalTestDriver.LINKTRANSLATION;
823:                } catch (EJBException e) {
824:                    if (checkEJBException(e, NullPointerException.class)) {
825:                        return MediaEntityLocalTestDriver.NULLPOINTER;
826:                    } else if (checkEJBException(e,
827:                            IllegalArgumentException.class)) {
828:                        return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
829:                    } else {
830:                        throw e;
831:                    }
832:                }
833:                return 0;
834:            }
835:
836:            public int publishMediaExceptions(String[] playlist,
837:                    byte transferType, ProtocolConstraints constraints)
838:                    throws MediaException, NamingException, FinderException {
839:                try {
840:                    publishMediaEntityBeans(playlist, transferType, constraints);
841:                } catch (NullPointerException e) {
842:                    return MediaEntityLocalTestDriver.NULLPOINTER;
843:                } catch (ContentAccessException e) {
844:                    return MediaEntityLocalTestDriver.CONTENTACCESS;
845:                } catch (MediaFormatException e) {
846:                    return MediaEntityLocalTestDriver.MEDIAFORMAT;
847:                } catch (NoServerFoundException e) {
848:                    return MediaEntityLocalTestDriver.NOSERVERFOUND;
849:                } catch (IllegalArgumentException e) {
850:                    return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
851:                } catch (ConversionException e) {
852:                    return MediaEntityLocalTestDriver.CONVERSION;
853:                } catch (LinkTranslationException e) {
854:                    return MediaEntityLocalTestDriver.LINKTRANSLATION;
855:                } catch (EJBException e) {
856:                    if (checkEJBException(e, NullPointerException.class)) {
857:                        return MediaEntityLocalTestDriver.NULLPOINTER;
858:                    } else if (checkEJBException(e,
859:                            IllegalArgumentException.class)) {
860:                        return MediaEntityLocalTestDriver.ILLEGALARGUMENT;
861:                    } else {
862:                        throw e;
863:                    }
864:                }
865:                return 0;
866:            }
867:
868:            public int listenerAboutToChangeMEB(MediaListener listener,
869:                    String pk, String property) throws FinderException,
870:                    NamingException, MediaException {
871:                if (listener == null) {
872:                    return MediaEntityLocalTestDriver.NULLPOINTER;
873:                }
874:                MediaEntityLocal meb = null;
875:                if (pk != null)
876:                    meb = getMebHome().findByPrimaryKey(pk);
877:                try {
878:                    listener.handleAboutToChangeMediaEntity(meb, property);
879:                } catch (NullPointerException e) {
880:                    return MediaEntityLocalTestDriver.NULLPOINTER;
881:                } catch (EJBException e) {
882:                    if (checkEJBException(e, NullPointerException.class)) {
883:                        return MediaEntityLocalTestDriver.NULLPOINTER;
884:                    } else {
885:                        throw e;
886:                    }
887:                }
888:                return 0;
889:            }
890:
891:            public int listenerMediaEntityChanged(MediaListener listener,
892:                    String pk, String property) throws FinderException,
893:                    NamingException, MediaException {
894:                if (listener == null) {
895:                    return MediaEntityLocalTestDriver.NULLPOINTER;
896:                }
897:                MediaEntityLocal meb = null;
898:                if (pk != null)
899:                    meb = getMebHome().findByPrimaryKey(pk);
900:                try {
901:                    listener.handleMediaEntityChanged(meb, property);
902:                } catch (NullPointerException e) {
903:                    return MediaEntityLocalTestDriver.NULLPOINTER;
904:                } catch (EJBException e) {
905:                    if (checkEJBException(e, NullPointerException.class)) {
906:                        return MediaEntityLocalTestDriver.NULLPOINTER;
907:                    } else {
908:                        throw e;
909:                    }
910:                }
911:                return 0;
912:            }
913:
914:            public int listenerAboutToRemoveMEB(MediaListener listener,
915:                    String pk) throws FinderException, NamingException,
916:                    MediaException {
917:                if (listener == null) {
918:                    return MediaEntityLocalTestDriver.NULLPOINTER;
919:                }
920:                MediaEntityLocal meb = null;
921:                if (pk != null)
922:                    meb = getMebHome().findByPrimaryKey(pk);
923:                try {
924:                    listener.handleAboutToRemoveMediaEntity(meb);
925:                } catch (NullPointerException e) {
926:                    return MediaEntityLocalTestDriver.NULLPOINTER;
927:                } catch (EJBException e) {
928:                    if (checkEJBException(e, NullPointerException.class)) {
929:                        return MediaEntityLocalTestDriver.NULLPOINTER;
930:                    } else {
931:                        throw e;
932:                    }
933:                }
934:                return 0;
935:            }
936:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.