001: package com.ibm.emb.meb.wrapper;
002:
003: import java.util.Collection;
004: import java.util.Iterator;
005:
006: import javax.ejb.CreateException;
007: import javax.ejb.FinderException;
008: import javax.ejb.RemoveException;
009: import javax.emb.MediaEntityLocal;
010: import javax.emb.MediaEntityLocalHome;
011: import javax.emb.MediaException;
012: import javax.emb.MediaFormat;
013: import javax.emb.MetaDataEntityLocal;
014: import javax.emb.MetaDataEntityLocalHome;
015: import javax.naming.InitialContext;
016: import javax.naming.NamingException;
017:
018: /**
019: * Bean implementation class for Enterprise Bean: MetaDataEntityWrapper
020: */
021: public class MetaDataEntityWrapperBean implements javax.ejb.SessionBean {
022:
023: /**
024: *
025: */
026: private static final long serialVersionUID = 4049358625720054070L;
027:
028: private static String MEBHOME_JNDI = "java:comp/env/ejb/emb/MediaEntityLocalHome";
029:
030: private static String MDEBHOME_JNDI = "java:comp/env/ejb/emb/MetaDataEntityLocalHome";
031:
032: private javax.ejb.SessionContext mySessionCtx;
033:
034: private MediaEntityLocalHome meb_home;
035:
036: private MetaDataEntityLocalHome mdeb_home;
037:
038: private InitialContext ic;
039:
040: /**
041: * getSessionContext
042: */
043: public javax.ejb.SessionContext getSessionContext() {
044: return mySessionCtx;
045: }
046:
047: /**
048: * setSessionContext
049: */
050: public void setSessionContext(javax.ejb.SessionContext ctx) {
051: mySessionCtx = ctx;
052: }
053:
054: /**
055: * ejbCreate
056: */
057: public void ejbCreate() throws javax.ejb.CreateException {
058: }
059:
060: /**
061: * ejbActivate
062: */
063: public void ejbActivate() {
064: }
065:
066: /**
067: * ejbPassivate
068: */
069: public void ejbPassivate() {
070: }
071:
072: /**
073: * ejbRemove
074: */
075: public void ejbRemove() {
076: }
077:
078: /*
079: * MetaDataEntityLocalHome Wrapped Methods
080: */
081:
082: /**
083: * Invokes create() on MetaDataEntityLocalHome. Returns the Primary Key of
084: * the created MetaDataEntityLocal Throws any exceptions originating from
085: * the call to MetaDataEntityLocalHome
086: * @return String - primary key coresponding to the created
087: * MetaDataEntityBean
088: * @exception MediaException thrown if the exception was thrown by the
089: * MetaDataEntityLocalHome import operation
090: * @exception NamingException thrown if there are problems looking up the
091: * MetaDataEntityLocalHome
092: * @exception CreateException thrown if the exception was thrown by the
093: * MetaDataEntityLocalHome import operation
094: */
095: public String createMetaDataEntityBean() throws MediaException,
096: CreateException, NamingException {
097: MetaDataEntityLocal mdeb = getMdebHome().create();
098: return (String) mdeb.getPrimaryKey();
099: }
100:
101: /*
102: * Invokes remove() for the entity indicated by the key
103: */
104: public void removeMetaDataEntity(String key)
105: throws RemoveException, NamingException {
106: getMdebHome().remove(key);
107: }
108:
109: /**
110: * Invokes create() on MediaEntityLocalHome. Returns the Primary Key of the
111: * created MediaEntityLocal Throws any exceptions originating from the call
112: * to MediaEntityLocalHome
113: * @return String - primary key coresponding to the created MediaEntityBean
114: * @exception MediaException thrown if the exception was thrown by the
115: * MediaEntityLocalHome import operation
116: * @exception NamingException thrown if there are problems looking up the
117: * MediaEntityLocalHome
118: * @exception CreateException thrown if the exception was thrown by the
119: * MediaEntityLocalHome import operation
120: */
121: public String createMediaEntityBean() throws MediaException,
122: CreateException, NamingException {
123: MediaEntityLocal meb = getMebHome().create();
124: return (String) meb.getPrimaryKey();
125: }
126:
127: /**
128: * Invokes findByPrimaryKey(String) on MetaDataEntityLocalHome The primary
129: * key passed in and the primary key returned should be the same (or the
130: * operation has failed) however no validation checking is done by this
131: * method.
132: * @param pk - String representing primary key to find in the datastore
133: * @return String - primary key of the located MetaDataEntityBean
134: * @exception NamingException thrown if there are problems looking up the
135: * MetaDataEntityLocalHome
136: * @exception FinderException thrown if the primary key can not be found in
137: * the datastore
138: */
139: public String findMDEBByPrimaryKey(String pk)
140: throws NamingException, FinderException {
141: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
142: return (String) mdeb.getPrimaryKey();
143: }
144:
145: /**
146: * Invokes the query(String, String, String) on MetaDataEntityLocalHome An
147: * array of primary keys is built from the collection of located
148: * MetaDataEntityBeans and returned.
149: * @param query - String representing the partial description to search for
150: * @param queryLang - String representing the query language to use
151: * @param options - String representing the options for the query language
152: * @return String[] - array of primary keys of located MediaEntityBeans
153: * matching the partial description
154: * @throws MediaException thrown if the exception was thrown by the
155: * MetaDataEntityLocalHome operation
156: * @throws NamingException thrown if there are problems looking up the
157: * MediaEntityLocalHome
158: * @throws FinderException thrown if no MediaEntityBeans can be found by the
159: * partial description
160: */
161: public String[] queryMetaDataEntity(String query, String queryLang,
162: java.util.Map options) throws MediaException,
163: NamingException, FinderException {
164: Collection mdebs = getMdebHome().query(query, queryLang,
165: options);
166: Iterator i = mdebs.iterator();
167: String[] pks = new String[mdebs.size()];
168: int index = 0;
169: while (i.hasNext()) {
170: pks[index++] = (String) ((MetaDataEntityLocal) i.next())
171: .getPrimaryKey();
172: }
173: return pks;
174: }
175:
176: /**
177: * Invokes the retrieveSupportedQueryLanguages on MetaDataEntityLocalHome
178: * @throws MediaException thrown if the exception was thrown by the
179: * MetaDataEntityLocalHome operation
180: * @throws NamingException thrown if there are problems looking up the
181: * MediaEntityLocalHome
182: */
183: public String[] retrieveMetaDataEntitySupportedQueryLanguages()
184: throws MediaException, NamingException {
185: return getMdebHome().retrieveSupportedQueryLanguages();
186: }
187:
188: /**
189: * Invokes the retrieveSupportedOptions on MetaDataEntityLocalHome
190: * @throws MediaException thrown if the exception was thrown by the
191: * MetaDataEntityLocalHome operation
192: * @throws NamingException thrown if there are problems looking up the
193: * MediaEntityLocalHome
194: */
195: public String[] retrieveMetaDataEntitySupportedOptions(
196: String queryLang) throws MediaException, NamingException {
197: return getMdebHome().retrieveSupportedOptions(queryLang);
198: }
199:
200: /*
201: * MetaDataEntityLocal Wrapped Methods
202: */
203:
204: /**
205: * Invokes addChild(MetaDataEntityLocal) on the MetaDataEntityLocal The
206: * primary key passed will first be resolved to a MetaDataEntityBean on
207: * which the operation should be invoked on. If the child primary key is not
208: * null, it will be resolved to a MetaDataEntityBean before it is passed in
209: * to the method. If the child is null, null is passed in.
210: * @param pk - String representing the primary key of the MetaDataEntityBean
211: * to invoke the operation on
212: * @param childpk - String representing the primary key of the child
213: * MetaDataEntityLocal
214: * @exception NullPointerException - thrown if the primary key passed in is
215: * null
216: * @exception MediaException thrown if the exception was thrown by the
217: * MetaDataEntityLocal operation
218: * @exception NamingException thrown if there are problems looking up the
219: * MetaDataEntityLocalHome
220: * @exception FinderException thrown if either primary key can not be found
221: * in the datastore
222: */
223: public void addMetaDataChild(String pk, String childpk)
224: throws MediaException, NamingException, FinderException {
225: if (pk == null)
226: throw new NullPointerException(
227: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
228: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
229:
230: MetaDataEntityLocal child = null;
231: if (childpk != null)
232: child = getMdebHome().findByPrimaryKey(childpk);
233: mdeb.addChild(child);
234: }
235:
236: /**
237: * Invokes addMediaEntity(MediaEntityLocal) on the MetaDataEntityLocal The
238: * primary key passed will first be resolved to a MetaDataEntityBean on
239: * which the operation should be invoked on. If the media primary key is not
240: * null, it will be resolved to a MediaEntityBean before it is passed in to
241: * the method. If the child is null, null is passed in.
242: * @param pk - String representing the primary key of the MetaDataEntityBean
243: * to invoke the operation on
244: * @param childpk - String representing the primary key of the media
245: * MediaEntityLocal
246: * @exception NullPointerException - thrown if the primary key passed in is
247: * null
248: * @exception MediaException thrown if the exception was thrown by the
249: * MetaDataEntityLocal operation
250: * @exception NamingException thrown if there are problems looking up the
251: * MetaDataEntityLocalHome
252: * @exception FinderException thrown if either primary key can not be found
253: * in the datastore
254: */
255: public void addMetaDataMedia(String pk, String mediapk)
256: throws MediaException, NamingException, FinderException {
257: if (pk == null)
258: throw new NullPointerException(
259: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
260: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
261:
262: MediaEntityLocal media = null;
263: if (mediapk != null)
264: media = getMebHome().findByPrimaryKey(mediapk);
265: mdeb.addMediaEntity(media);
266: }
267:
268: /**
269: * Invokes findContentByFormat(MediaFormat, boolean) on the
270: * MetaDataEntityLocal The primary key passed will first be resolved to a
271: * MetaDataEntityBean on which the operation should be invoked on.
272: * @param pk - String representing the primary key of the MetaDataEntityBean
273: * to invoke the operation on
274: * @param format - MediaFormat object to be passed
275: * @param recursive - if true, children are searched too
276: * @exception NullPointerException - thrown if the primary key passed in is
277: * null
278: * @exception MediaException thrown if the exception was thrown by the
279: * MetaDataEntityLocal operation
280: * @exception NamingException thrown if there are problems looking up the
281: * MetaDataEntityLocalHome
282: * @exception FinderException thrown if either primary key can not be found
283: * in the datastore
284: */
285: public String[] getMetaDataEntityMediaEntities(String pk,
286: MediaFormat format, boolean searchChildren)
287: throws MediaException, NamingException, FinderException {
288: if (pk == null)
289: throw new NullPointerException(
290: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
291: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
292:
293: MediaEntityLocal[] media = mdeb.getMediaEntities(format,
294: searchChildren);
295: String[] mediapks = new String[media.length];
296: for (int i = 0; i < mediapks.length; i++) {
297: mediapks[i] = (String) media[i].getPrimaryKey();
298: }
299: return mediapks;
300: }
301:
302: /**
303: * Invokes findContentByMimeType(MediaFormat, boolean) on the
304: * MetaDataEntityLocal The primary key passed will first be resolved to a
305: * MetaDataEntityBean on which the operation should be invoked on.
306: * @param pk - String representing the primary key of the MetaDataEntityBean
307: * to invoke the operation on
308: * @param mimeType - String representing the mime type to be passed
309: * @param recursive - if true, children are searched too
310: * @exception NullPointerException - thrown if the primary key passed in is
311: * null
312: * @exception MediaException thrown if the exception was thrown by the
313: * MetaDataEntityLocal operation
314: * @exception NamingException thrown if there are problems looking up the
315: * MetaDataEntityLocalHome
316: * @exception FinderException thrown if either primary key can not be found
317: * in the datastore
318: */
319: public String[] getMetaDataEntityMediaEntities(String pk,
320: String mimeType, boolean searchChildren)
321: throws MediaException, NamingException, FinderException {
322: if (pk == null)
323: throw new NullPointerException(
324: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
325: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
326:
327: MediaEntityLocal[] media = mdeb.getMediaEntities(mimeType,
328: searchChildren);
329: String[] mediapks = new String[media.length];
330: for (int i = 0; i < mediapks.length; i++) {
331: mediapks[i] = (String) media[i].getPrimaryKey();
332: }
333: return mediapks;
334: }
335:
336: /**
337: * Invokes setXML(String, String, boolean) on the MetaDataEntityLocal The
338: * primary key passed will first be resolved to a MetaDataEntityBean on
339: * which the operation should be invoked on.
340: * @param pk - String representing the primary key of the MetaDataEntityBean
341: * to invoke the operation on
342: * @param xmlContent - String containing the xml metadata to set on the
343: * MetaDataEntityBean
344: * @param validate - boolean flag for enabling validation of the xml
345: * @exception NullPointerException - thrown if the primary key passed in is
346: * null
347: * @throws MediaException thrown if the exception was thrown by the
348: * MetaDataEntityLocal operation
349: * @throws NamingException thrown if there are problems looking up the
350: * MetaDataEntityLocalHome
351: * @throws FinderException thrown if either primary key can not be found in
352: * the datastore
353: */
354: public void setMetaDataEntityXML(String pk, String xmlContent,
355: boolean validate) throws MediaException, NamingException,
356: FinderException {
357: if (pk == null)
358: throw new NullPointerException(
359: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
360: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
361:
362: mdeb.setXML(xmlContent, validate);
363: }
364:
365: /**
366: * Invokes getXML(String) on the MetaDataEntityLocal The primary key passed
367: * will first be resolved to a MetaDataEntityBean on which the operation
368: * should be invoked on.
369: * @param pk - String representing the primary key of the MetaDataEntityBean
370: * to invoke the operation on
371: * @exception NullPointerException - thrown if the primary key passed in is
372: * null
373: * @throws MediaException thrown if the exception was thrown by the
374: * MetaDataEntityLocal operation
375: * @throws NamingException thrown if there are problems looking up the
376: * MetaDataEntityLocalHome
377: * @throws FinderException thrown if either primary key can not be found in
378: * the datastore
379: */
380: public String getMetaDataEntityXML(String pk)
381: throws MediaException, NamingException, FinderException {
382: if (pk == null)
383: throw new NullPointerException(
384: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
385: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
386: return mdeb.getXML();
387: }
388:
389: /**
390: * Invokes getChildren() on the MetaDataEntityLocal The primary key passed
391: * will first be resolved to a MetaDataEntityBean on which the operation
392: * should be invoked on. The array of MetaDataEntityBean children will first
393: * be converted into an array of primary keys representing the children
394: * before being returned.
395: * @param pk - String representing the primary key of the MetaDataEntityBean
396: * to invoke the operation on
397: * @return String array of primary keys representing the children on the
398: * MetaDataEntityBean
399: * @exception NullPointerException - thrown if the primary key passed in is
400: * null
401: * @exception MediaException thrown if the exception was thrown by the
402: * MetaDataEntityLocal operation
403: * @exception NamingException thrown if there are problems looking up the
404: * MetaDataEntityLocalHome
405: * @exception FinderException thrown if the primary key can not be found in
406: * the datastore
407: */
408: public String[] getMetaDataEntityChildren(String pk)
409: throws NamingException, FinderException, MediaException {
410: if (pk == null)
411: throw new NullPointerException(
412: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
413: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
414: MetaDataEntityLocal[] children = mdeb.getChildren();
415: String[] childpks = new String[children.length];
416: for (int i = 0; i < childpks.length; i++) {
417: childpks[i] = (String) children[i].getPrimaryKey();
418: }
419: return childpks;
420: }
421:
422: /**
423: * Invokes getLastModified() on the MetaDataEntityLocal The primary key
424: * passed will first be resolved to a MetaDataEntityBean on which the
425: * operation should be invoked on.
426: * @param pk - String representing the primary key of the MetaDataEntityBean
427: * to invoke the operation on
428: * @return long representing the timestamp of when MetaDataEntityBean was
429: * last modified
430: * @exception NullPointerException - thrown if the primary key passed in is
431: * null
432: * @exception MediaException thrown if the exception was thrown by the
433: * MetaDataEntityLocal operation
434: * @exception NamingException thrown if there are problems looking up the
435: * MetaDataEntityLocalHome
436: * @exception FinderException thrown if the primary key can not be found in
437: * the datastore
438: */
439: public long getMetaDataEntityLastModified(String pk)
440: throws NamingException, FinderException, MediaException {
441: if (pk == null)
442: throw new NullPointerException(
443: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
444: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
445: return mdeb.getLastModified();
446: }
447:
448: /**
449: * Invokes getMediaEntities() on the MetaDataEntityLocal The primary key
450: * passed will first be resolved to a MetaDataEntityBean on which the
451: * operation should be invoked on. The array of MediaEntity children is
452: * converted into an array of primary keys representing the children before
453: * being returned.
454: * @param pk - String representing the primary key of the MetaDataEntityBean
455: * to invoke the operation on
456: * @return String array of primary keys representing the associated
457: * MediaEntityBeans
458: * @exception NullPointerException - thrown if the primary key passed in is
459: * null
460: * @exception MediaException thrown if the exception was thrown by the
461: * MetaDataEntityLocal operation
462: * @exception NamingException thrown if there are problems looking up the
463: * MetaDataEntityLocalHome
464: * @exception FinderException thrown if the primary key can not be found in
465: * the datastore
466: */
467: public String[] getMetaDataEntityMediaEntities(String pk)
468: throws NamingException, FinderException, MediaException {
469: if (pk == null)
470: throw new NullPointerException(
471: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
472: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
473: MediaEntityLocal[] media = mdeb.getMediaEntities();
474: String[] mediapks = new String[media.length];
475: for (int i = 0; i < mediapks.length; i++) {
476: mediapks[i] = (String) media[i].getPrimaryKey();
477: }
478: return mediapks;
479: }
480:
481: /**
482: * Invokes getName() on the MetaDataEntityLocal The primary key passed will
483: * first be resolved to a MetaDataEntityBean on which the operation should
484: * be invoked on.
485: * @param pk - String representing the primary key of the MetaDataEntityBean
486: * to invoke the operation on
487: * @return String representing the name of the MetaDataEntityBean
488: * @exception NullPointerException - thrown if the primary key passed in is
489: * null
490: * @exception MediaException thrown if the exception was thrown by the
491: * MetaDataEntityLocal operation
492: * @exception NamingException thrown if there are problems looking up the
493: * MetaDataEntityLocalHome
494: * @exception FinderException thrown if the primary key can not be found in
495: * the datastore
496: */
497: public String getMetaDataEntityName(String pk)
498: throws NamingException, FinderException, MediaException {
499: if (pk == null)
500: throw new NullPointerException(
501: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
502: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
503: return mdeb.getName();
504: }
505:
506: /**
507: * Invokes getNextVersion() on the MetaDataEntityLocal The primary key
508: * passed will first be resolved to a MetaDataEntityBean on which the
509: * operation should be invoked on. The primary key of the
510: * MetaDataEntityBean's next version MetaDataEntityBean will be returned or
511: * null if the next version is null.
512: * @param pk - String representing the primary key of the MetaDataEntityBean
513: * to invoke the operation on
514: * @return String representing the primary key of the MetaDataEntityBean's
515: * next version or null
516: * @exception NullPointerException - thrown if the primary key passed in is
517: * null
518: * @exception MediaException thrown if the exception was thrown by the
519: * MetaDataEntityLocal operation
520: * @exception NamingException thrown if there are problems looking up the
521: * MetaDataEntityLocalHome
522: * @exception FinderException thrown if the primary key can not be found in
523: * the datastore
524: */
525: public String getMetaDataEntityNextVersion(String pk)
526: throws NamingException, FinderException, MediaException {
527: if (pk == null)
528: throw new NullPointerException(
529: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
530: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
531: MetaDataEntityLocal nextmdeb = mdeb.getNextVersion();
532: if (nextmdeb == null)
533: return null;
534: else
535: return (String) nextmdeb.getPrimaryKey();
536: }
537:
538: /**
539: * Invokes getParents() on the MetaDataEntityLocal The primary key passed
540: * will first be resolved to a MetaDataEntityBean on which the operation
541: * should be invoked on. The array of MetaDataEntityBean parents will first
542: * be converted into an array of primary keys representing the parents
543: * before being returned.
544: * @param pk - String representing the primary key of the MetaDataEntityBean
545: * to invoke the operation on
546: * @return String array of primary keys representing the parents on the
547: * MetaDataEntityBean
548: * @exception NullPointerException - thrown if the primary key passed in is
549: * null
550: * @exception MediaException thrown if the exception was thrown by the
551: * MetaDataEntityLocal operation
552: * @exception NamingException thrown if there are problems looking up the
553: * MetaDataEntityLocalHome
554: * @exception FinderException thrown if the primary key can not be found in
555: * the datastore
556: */
557: public String[] getMetaDataEntityParents(String pk)
558: throws NamingException, FinderException, MediaException {
559: if (pk == null)
560: throw new NullPointerException(
561: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
562: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
563: MetaDataEntityLocal[] parents = mdeb.getParents();
564: String[] parentpks = new String[parents.length];
565: for (int i = 0; i < parentpks.length; i++) {
566: parentpks[i] = (String) parents[i].getPrimaryKey();
567: }
568: return parentpks;
569: }
570:
571: /**
572: * Invokes getPreviousVersion() on the MetaDataEntityLocal The primary key
573: * passed will first be resolved to a MetaDataEntityBean on which the
574: * operation should be invoked on. The primary key of the
575: * MetaDataEntityBean's previous version MetaDataEntityBean will be returned
576: * or null if the next version is null.
577: * @param pk - String representing the primary key of the MetaDataEntityBean
578: * to invoke the operation on
579: * @return String representing the primary key of the MetaDataEntityBean's
580: * previous version or null
581: * @exception NullPointerException - thrown if the primary key passed in is
582: * null
583: * @exception MediaException thrown if the exception was thrown by the
584: * MetaDataEntityLocal operation
585: * @exception NamingException thrown if there are problems looking up the
586: * MetaDataEntityLocalHome
587: * @exception FinderException thrown if the primary key can not be found in
588: * the datastore
589: */
590: public String getMetaDataEntityPreviousVersion(String pk)
591: throws NamingException, FinderException, MediaException {
592: if (pk == null)
593: throw new NullPointerException(
594: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
595: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
596: MetaDataEntityLocal prevmdeb = mdeb.getPreviousVersion();
597: if (prevmdeb == null)
598: return null;
599: else
600: return (String) prevmdeb.getPrimaryKey();
601: }
602:
603: /**
604: * Invokes removeChild(MetaDataEntityLocal) on the MetaDataEntityLocal The
605: * primary key passed will first be resolved to a MetaDataEntityBean on
606: * which the operation should be invoked on. If the child primary key is not
607: * null, it will be resolved to a MetaDataEntityBean before it is passed in
608: * to the method. If the child is null, null is passed in.
609: * @param pk - String representing the primary key of the MetaDataEntityBean
610: * to invoke the operation on
611: * @param childpk - String representing the primary key of the child
612: * MetaDataEntityLocal
613: * @exception NullPointerException - thrown if the primary key passed in is
614: * null
615: * @exception MediaException thrown if the exception was thrown by the
616: * MetaDataEntityLocal operation
617: * @exception NamingException thrown if there are problems looking up the
618: * MetaDataEntityLocalHome
619: * @exception FinderException thrown if either primary key can not be found
620: * in the datastore
621: */
622: public void removeMetaDataChild(String pk, String childpk)
623: throws MediaException, NamingException, FinderException {
624: if (pk == null)
625: throw new NullPointerException(
626: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
627: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
628:
629: MetaDataEntityLocal child = null;
630: if (childpk != null)
631: child = getMdebHome().findByPrimaryKey(childpk);
632: mdeb.removeChild(child);
633: }
634:
635: /**
636: * Invokes removeMediaEntity(MediaEntityLocal) on the MetaDataEntityLocal
637: * The primary key passed will first be resolved to a MetaDataEntityBean on
638: * which the operation should be invoked on. If the media primary key is not
639: * null, it will be resolved to a MediaEntityBean before it is passed in to
640: * the method. If the child is null, null is passed in.
641: * @param pk - String representing the primary key of the MetaDataEntityBean
642: * to invoke the operation on
643: * @param childpk - String representing the primary key of the media
644: * MediaEntityLocal
645: * @exception NullPointerException - thrown if the primary key passed in is
646: * null
647: * @exception MediaException thrown if the exception was thrown by the
648: * MetaDataEntityLocal operation
649: * @exception NamingException thrown if there are problems looking up the
650: * MetaDataEntityLocalHome
651: * @exception FinderException thrown if either primary key can not be found
652: * in the datastore
653: */
654: public void removeMetaDataMedia(String pk, String mediapk)
655: throws MediaException, NamingException, FinderException {
656: if (pk == null)
657: throw new NullPointerException(
658: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
659: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
660:
661: MediaEntityLocal media = null;
662: if (mediapk != null)
663: media = getMebHome().findByPrimaryKey(mediapk);
664: mdeb.removeMediaEntity(media);
665: }
666:
667: /**
668: * Invokes setName() on the MetaDataEntityLocal The primary key passed will
669: * first be resolved to a MetaDataEntityBean on which the operation should
670: * be invoked on.
671: * @param pk - String representing the primary key of the MetaDataEntityBean
672: * to invoke the operation on
673: * @param name - String representing the name of the MetaDataEntityBean
674: * @exception NullPointerException - thrown if the primary key passed in is
675: * null
676: * @exception MediaException thrown if the exception was thrown by the
677: * MetaDataEntityLocal operation
678: * @exception NamingException thrown if there are problems looking up the
679: * MetaDataEntityLocalHome
680: * @exception FinderException thrown if the primary key can not be found in
681: * the datastore
682: */
683: public void setMetaDataEntityName(String pk, String name)
684: throws NamingException, FinderException, MediaException {
685: if (pk == null)
686: throw new NullPointerException(
687: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
688: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
689: mdeb.setName(name);
690: }
691:
692: /**
693: * Invokes setPreviousVersion(MetaDataEntityLocal) on the
694: * MetaDataEntityLocal The primary key passed will first be resolved to a
695: * MetaDataEntityBean on which the operation should be invoked on. The
696: * primary key passed representing the MetaDataEntityBean's previous version
697: * MetaDataEntityBean will be located in the datastore and resolved to a
698: * MetaDataEntityLocal before it is passed into the setter. If the primary
699: * key representing the previous version is null then null will be passed
700: * in.
701: * @param pk - String representing the primary key of the MetaDataEntityBean
702: * to invoke the operation on
703: * @param pvpk - String representing the primary key of the
704: * MetaDataEntityBean's previous version or null
705: * @exception NullPointerException - thrown if the primary key passed in is
706: * null
707: * @exception MediaException thrown if the exception was thrown by the
708: * MetaDataEntityLocal operation
709: * @exception NamingException thrown if there are problems looking up the
710: * MetaDataEntityLocalHome
711: * @exception FinderException thrown if the primary key can not be found in
712: * the datastore
713: */
714: public void setMetaDataEntityPreviousVersion(String pk, String pvpk)
715: throws NamingException, FinderException, MediaException {
716: if (pk == null)
717: throw new NullPointerException(
718: "mdeb Primary Key provided is null, please specify a non-null primary key for this operation");
719: MetaDataEntityLocal mdeb = getMdebHome().findByPrimaryKey(pk);
720: MetaDataEntityLocal prevmdeb = null;
721: if (pvpk != null)
722: prevmdeb = getMdebHome().findByPrimaryKey(pvpk);
723: mdeb.setPreviousVersion(prevmdeb);
724: }
725:
726: /*
727: * Helper Methods
728: */
729:
730: private MediaEntityLocalHome getMebHome() throws NamingException {
731: if (meb_home == null)
732: meb_home = (MediaEntityLocalHome) getInitialContext()
733: .lookup(MEBHOME_JNDI);
734: return meb_home;
735: }
736:
737: private MetaDataEntityLocalHome getMdebHome()
738: throws NamingException {
739: if (mdeb_home == null)
740: mdeb_home = (MetaDataEntityLocalHome) getInitialContext()
741: .lookup(MDEBHOME_JNDI);
742: return mdeb_home;
743: }
744:
745: private InitialContext getInitialContext() throws NamingException {
746: if (ic == null)
747: ic = new InitialContext();
748: return ic;
749: }
750:
751: }
|