0001: package com.ibm.emb.meb.wrapper;
0002:
0003: import java.io.ByteArrayInputStream;
0004: import java.io.File;
0005: import java.io.FileInputStream;
0006: import java.io.FileNotFoundException;
0007: import java.net.URL;
0008: import java.util.Collection;
0009: import java.util.Iterator;
0010:
0011: import javax.ejb.CreateException;
0012: import javax.ejb.FinderException;
0013: import javax.emb.Media;
0014: import javax.emb.MediaBean;
0015: import javax.emb.MediaConverterSpec;
0016: import javax.emb.MediaEntityLocal;
0017: import javax.emb.MediaEntityLocalHome;
0018: import javax.emb.MediaException;
0019: import javax.emb.MediaFormat;
0020: import javax.emb.MediaHeader;
0021: import javax.emb.MediaListener;
0022: import javax.emb.MetaDataEntityLocal;
0023: import javax.emb.MetaDataEntityLocalHome;
0024: import javax.emb.ProtocolConstraints;
0025: import javax.naming.InitialContext;
0026: import javax.naming.NamingException;
0027:
0028: /**
0029: * Bean implementation class for Enterprise Bean: MediaEntityWrapper
0030: */
0031: public class MediaEntityWrapperBean implements javax.ejb.SessionBean {
0032:
0033: /**
0034: *
0035: */
0036: private static final long serialVersionUID = 3689348814725263664L;
0037:
0038: private static String MEBHOME_JNDI = "java:comp/env/ejb/emb/MediaEntityLocalHome";
0039:
0040: private static String MDEBHOME_JNDI = "java:comp/env/ejb/emb/MetaDataEntityLocalHome";
0041:
0042: private javax.ejb.SessionContext mySessionCtx;
0043:
0044: private MediaEntityLocalHome meb_home;
0045:
0046: private MetaDataEntityLocalHome mdeb_home;
0047:
0048: private InitialContext ic;
0049:
0050: /**
0051: * getSessionContext
0052: */
0053: public javax.ejb.SessionContext getSessionContext() {
0054: return mySessionCtx;
0055: }
0056:
0057: /**
0058: * setSessionContext
0059: */
0060: public void setSessionContext(javax.ejb.SessionContext ctx) {
0061: mySessionCtx = ctx;
0062: }
0063:
0064: /**
0065: * ejbCreate
0066: */
0067: public void ejbCreate() throws javax.ejb.CreateException {
0068: }
0069:
0070: /**
0071: * ejbActivate
0072: */
0073: public void ejbActivate() {
0074: }
0075:
0076: /**
0077: * ejbPassivate
0078: */
0079: public void ejbPassivate() {
0080: }
0081:
0082: /**
0083: * ejbRemove
0084: */
0085: public void ejbRemove() {
0086: }
0087:
0088: /*
0089: * MediaEntityLocalHome Wrapped Methods
0090: */
0091:
0092: /**
0093: * Invokes create() on MediaEntityLocalHome. Returns the Primary Key of the
0094: * created MediaEntityLocal Throws any exceptions originating from the call
0095: * to MediaEntityLocalHome
0096: *
0097: * @return String - primary key coresponding to the created MediaEntityBean
0098: * @exception MediaException thrown if the exception was thrown by the
0099: * MediaEntityLocalHome import operation
0100: * @exception NamingException thrown if there are problems looking up the
0101: * MediaEntityLocalHome
0102: * @exception CreateException thrown if the exception was thrown by the
0103: * MediaEntityLocalHome import operation
0104: */
0105: public String createMediaEntityBean() throws MediaException,
0106: CreateException, NamingException {
0107: MediaEntityLocal meb = getMebHome().create();
0108: return (String) meb.getPrimaryKey();
0109: }
0110:
0111: /**
0112: * Invokes create() on MetaDataEntityLocalHome. Returns the Primary Key of
0113: * the created MetaDataEntityLocal Throws any exceptions originating from
0114: * the call to MediaEntityLocalHome
0115: *
0116: * @return String - primary key coresponding to the created MediaEntityBean
0117: * @exception MediaException thrown if the exception was thrown by the
0118: * MediaEntityLocalHome import operation
0119: * @exception NamingException thrown if there are problems looking up the
0120: * MediaEntityLocalHome
0121: * @exception CreateException thrown if the exception was thrown by the
0122: * MediaEntityLocalHome import operation
0123: */
0124: public String createMetaDataEntityBean() throws MediaException,
0125: CreateException, NamingException {
0126: MetaDataEntityLocal mdeb = getMdebHome().create();
0127: return (String) mdeb.getPrimaryKey();
0128: }
0129:
0130: /**
0131: * Invokes importMedia(URL[],String[]) on MediaEntityLocalHome. Returns an
0132: * array of Primary Keys matching the order of the returned
0133: * MediaEntityLocals. If one of the MediaEntityLocal elements in the array
0134: * returned from MediaEntityLocalHome is null, then coresponding null
0135: * element in the Primary Key array will be returned. Throws any exceptions
0136: * originating from the call to MediaEntityLocalHome
0137: *
0138: * @param urls - URL array of source URLs to import
0139: * @param names - String array of names to use when importing the content
0140: * @return String[] - array of primary keys coresponding to the created
0141: * MediaEntityLocals returned from the importMedia operation on the
0142: * home.
0143: * @exception MediaException thrown if the exception was thrown by the
0144: * MediaEntityLocalHome import operation
0145: * @exception NamingException thrown if there are problems looking up the
0146: * MediaEntityLocalHome
0147: * @exception CreateException thrown if the exception was thrown by the
0148: * MediaEntityLocalHome import operation
0149: */
0150: public String[] importHomeMediaEntityBeans(URL[] urls,
0151: String[] names) throws MediaException, NamingException,
0152: CreateException {
0153: MediaEntityLocal[] mebs = getMebHome().importMedia(urls, names);
0154: String[] pks = new String[mebs.length];
0155: for (int i = 0; i < mebs.length; i++) {
0156: if (mebs[i] == null)
0157: pks[i] = null;
0158: else
0159: pks[i] = (String) mebs[i].getPrimaryKey();
0160: }
0161: return pks;
0162: }
0163:
0164: /**
0165: * Invokes exportMedia(MediaEntityLocal[], URL) on MediaEntityLocalHome. An
0166: * array of MediaEntityLocals will be created from the array of primary keys
0167: * passed in. If one of the elements in the primary key array is null, a
0168: * coresponding null element will be placed in the created MediaEntityLocal
0169: * array.
0170: *
0171: * @param pks - String array of primary keys representing the
0172: * MediaEntityBeans to export
0173: * @param targetDir - URL representing the targetDirectory to export the
0174: * media to
0175: * @return URL[] - array of URLs representing the exported file location of
0176: * the MediaEntityBeans
0177: * @exception MediaException thrown if the exception was thrown by the
0178: * MediaEntityLocalHome import operation
0179: * @exception NamingException thrown if there are problems looking up the
0180: * MediaEntityLocalHome
0181: * @exception FinderException thrown if an element in the primary key array
0182: * can not be found in the datastore
0183: */
0184: public URL[] exportHomeMediaEntityBeans(String[] pks, URL targetDir)
0185: throws MediaException, NamingException, FinderException {
0186: MediaEntityLocal[] mebs = new MediaEntityLocal[pks.length];
0187: for (int i = 0; i < pks.length; i++) {
0188: if (pks[i] == null)
0189: mebs[i] = null;
0190: else
0191: mebs[i] = getMebHome().findByPrimaryKey(pks[i]);
0192: }
0193:
0194: URL[] urls = getMebHome().exportMedia(mebs, targetDir);
0195: return urls;
0196: }
0197:
0198: /**
0199: * Invokes findByPrimaryKey(String) on MediaEntityLocalHome The primary key
0200: * passed in and the primary key returned should be the same (or the
0201: * operation has failed) however no validation checking is done by this
0202: * method.
0203: *
0204: * @param pk - String representing primary key to find in the datastore
0205: * @return String - primary key of the located MediaEntityBean
0206: * @exception NamingException thrown if there are problems looking up the
0207: * MediaEntityLocalHome
0208: * @exception FinderException thrown if the primary key can not be found in
0209: * the datastore
0210: */
0211: public String findMEBByPrimaryKey(String pk)
0212: throws NamingException, FinderException {
0213: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0214: return (String) meb.getPrimaryKey();
0215: }
0216:
0217: /**
0218: * Invokes the findByPartialDescription(String) on MediaEntityLocalHome An
0219: * array of primary keys is built from the collection of located
0220: * MediaEntityBeans and returned.
0221: *
0222: * @param partialDesc - String representing the partial description to
0223: * search for
0224: * @return String[] - array of primary keys of located MediaEntityBeans
0225: * matching the partial description
0226: * @throws NamingException thrown if there are problems looking up the
0227: * MediaEntityLocalHome
0228: * @throws FinderException thrown if no MediaEntityBeans can be found by the
0229: * partial description
0230: */
0231: public String[] findMEBByPartialDescription(String partialDesc)
0232: throws NamingException, FinderException {
0233: Collection mebs = getMebHome().findByPartialDescription(
0234: partialDesc);
0235: Iterator i = mebs.iterator();
0236: String[] pks = new String[mebs.size()];
0237: int index = 0;
0238: while (i.hasNext()) {
0239: pks[index++] = (String) ((MediaEntityLocal) i.next())
0240: .getPrimaryKey();
0241: }
0242: return pks;
0243: }
0244:
0245: /**
0246: * Invokes the findByPartialLocation(String) on MediaEntityLocalHome An
0247: * array of primary keys is built from the collection of located
0248: * MediaEntityBeans and returned.
0249: *
0250: * @param partialLoc - String representing the partial location to search
0251: * for
0252: * @return String[] - array of primary keys of located MediaEntityBeans
0253: * matching the partial location
0254: * @throws NamingException thrown if there are problems looking up the
0255: * MediaEntityLocalHome
0256: * @throws FinderException thrown if no MediaEntityBeans can be found by the
0257: * partial location
0258: */
0259: public String[] findMEBByPartialLocation(String partialLoc)
0260: throws NamingException, FinderException {
0261: Collection mebs = getMebHome()
0262: .findByPartialLocation(partialLoc);
0263: Iterator i = mebs.iterator();
0264: String[] pks = new String[mebs.size()];
0265: int index = 0;
0266: while (i.hasNext()) {
0267: pks[index++] = (String) ((MediaEntityLocal) i.next())
0268: .getPrimaryKey();
0269: }
0270: return pks;
0271: }
0272:
0273: /**
0274: * Invokes the publishContent(Media, String, ProtocalConstraints) on
0275: * MediaEntityLocalHome The URL of the published media is returned.
0276: *
0277: * @param mediaobj - Media representing the transient or persistent media
0278: * object to publish
0279: * @param protocol - String representing the protocol to use when publishing
0280: * @param constraints - ProtocalConstraints containing the constraints to
0281: * publish with (if any)
0282: * @return URL representing the location of the published media
0283: * @throws MediaException thrown if the exception was thrown by the
0284: * MediaEntityLocalHome import operation
0285: * @throws NamingException thrown if there are problems looking up the
0286: * MediaEntityLocalHome
0287: */
0288: public URL publishMediaContent(Media mediaobj, byte protocol,
0289: ProtocolConstraints constraints) throws MediaException,
0290: NamingException {
0291: URL url = getMebHome().publishContent(mediaobj, protocol,
0292: constraints);
0293: return url;
0294: }
0295:
0296: /**
0297: * Invokes the publishMedia(MediaEntityLocal[], String, ProtocalConstraints)
0298: * on MediaEntityLocalHome The URL of the published media is returned. An
0299: * array of MediaEntityLocals will be created from the array of primary keys
0300: * passed in. If one of the elements in the primary key array is null, a
0301: * coresponding null element will be placed in the created MediaEntityLocal
0302: * array.
0303: *
0304: * @param pks - String array of primary keys representing the playlist of
0305: * MediaEntityBeans to publish
0306: * @param protocol - String representing the protocol to use when publishing
0307: * @param constraints - ProtocalConstraints containing the constraints to
0308: * publish with (if any)
0309: * @return URL representing the location of the published media
0310: * @throws MediaException thrown if the exception was thrown by the
0311: * MediaEntityLocalHome import operation
0312: * @throws NamingException thrown if there are problems looking up the
0313: * MediaEntityLocalHome
0314: * @exception FinderException thrown if an element in the primary key array
0315: * can not be found in the datastore
0316: */
0317: public Media publishMediaEntityBeans(String[] pks, byte protocol,
0318: ProtocolConstraints constraints) throws MediaException,
0319: NamingException, FinderException {
0320: MediaEntityLocal[] mebs = new MediaEntityLocal[pks.length];
0321: for (int i = 0; i < pks.length; i++) {
0322: if (pks[i] == null)
0323: mebs[i] = null;
0324: else
0325: mebs[i] = getMebHome().findByPrimaryKey(pks[i]);
0326: }
0327:
0328: Media mediaobj = getMebHome().publishMedia(mebs, protocol,
0329: constraints);
0330: // TODO : fixed to work, depend on spec interpretation, publish return a media and not mandatory a MediaBean
0331: if (mediaobj instanceof MediaEntityLocal) {
0332: mediaobj = new MediaBean(new ByteArrayInputStream(mediaobj
0333: .getContent()), mediaobj.getMimeType(), mediaobj
0334: .getName());
0335: }
0336: return mediaobj;
0337: }
0338:
0339: /*
0340: * MediaEntityLocal Wrapped Methods
0341: */
0342:
0343: /**
0344: * Invokes addListener(MediaListener) on the MediaEntityLocal The primary
0345: * key passed will first be resolved to a MediaEntityBean on which the
0346: * operation should be invoked on.
0347: *
0348: * @param pk - String representing the primary key of the MediaEntityBean to
0349: * invoke the operation on
0350: * @param listener - MediaListener representing the listener to add to the
0351: * MediaEntityBean
0352: * @exception NullPointerException - thrown if the primary key passed in is
0353: * null
0354: * @exception MediaException thrown if the exception was thrown by the
0355: * MediaEntityLocal operation
0356: * @exception NamingException thrown if there are problems looking up the
0357: * MediaEntityLocalHome
0358: * @exception FinderException thrown if the primary key can not be found in
0359: * the datastore
0360: */
0361: public void addMediaEntityListener(String pk, MediaListener listener)
0362: throws MediaException, NamingException, FinderException,
0363: NullPointerException {
0364: if (pk == null)
0365: throw new NullPointerException(
0366: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0367:
0368: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0369: meb.addListener(listener);
0370:
0371: return;
0372: }
0373:
0374: /**
0375: * Invokes addMetaData(MetaDataEntityLocal) on the MediaEntityLocal The MEB
0376: * primary key passed will first be resolved to a MediaEntityBean on which
0377: * the operation should be invoked on. If the MDEB primary key is not null,
0378: * it will be resolved to a MetaDataEntityBean before it is passed in to the
0379: * method. If the MDEB is null, null is passed in.
0380: *
0381: * @param mebpk - String representing the primary key of the MediaEntityBean
0382: * to invoke the operation on
0383: * @param mdebpk - String representing the primary key of the
0384: * MetaDataEntityBean to pass into the operation
0385: * @exception NullPointerException - thrown if the primary key passed in is
0386: * null
0387: * @exception MediaException thrown if the exception was thrown by the
0388: * MediaEntityLocal operation
0389: * @exception NamingException thrown if there are problems looking up the
0390: * MediaEntityLocalHome or the MetaDataEntityLocalHome
0391: * @exception FinderException thrown if either primary keys can not be found
0392: * in the datastore
0393: */
0394: public void addMediaEntityMetaData(String mebpk, String mdebpk)
0395: throws MediaException, NamingException, FinderException {
0396: if (mebpk == null)
0397: throw new NullPointerException(
0398: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0399: MediaEntityLocal meb = getMebHome().findByPrimaryKey(mebpk);
0400: MetaDataEntityLocal mdeb = null;
0401: if (mdebpk != null)
0402: mdeb = getMdebHome().findByPrimaryKey(mdebpk);
0403: meb.addMetaData(mdeb);
0404: return;
0405: }
0406:
0407: /**
0408: * Invokes convert(MediaConverterSpec[]) on the MediaEntityLocal The primary
0409: * key passed will first be resolved to a MediaEntityBean on which the
0410: * operation should be invoked on.
0411: *
0412: * @param pk - String representing the primary key of the MediaEntityBean to
0413: * invoke the operation on
0414: * @param specs - MediaConverterSpec array of media converters defining the
0415: * transformations to be done to the content.
0416: * @exception NullPointerException - thrown if the primary key passed in is
0417: * null
0418: * @exception MediaException thrown if the exception was thrown by the
0419: * MediaEntityLocal operation
0420: * @exception NamingException thrown if there are problems looking up the
0421: * MediaEntityLocalHome
0422: * @exception FinderException thrown if the primary key can not be found in
0423: * the datastore
0424: */
0425: public void convertMediaEntity(String pk, MediaConverterSpec[] specs)
0426: throws NamingException, FinderException, MediaException {
0427: if (pk == null)
0428: throw new NullPointerException(
0429: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0430: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0431: meb.convert(specs);
0432: return;
0433:
0434: }
0435:
0436: /**
0437: * Invokes exportMedia(URL) on the MediaEntityLocal The primary key passed
0438: * will first be resolved to a MediaEntityBean on which the operation should
0439: * be invoked on.
0440: *
0441: * @param pk - String representing the primary key of the MediaEntityBean to
0442: * invoke the operation on
0443: * @param loc - URL representing the targetlocation to export
0444: * @return URL with the location of the exported Media
0445: * @exception NullPointerException - thrown if the primary key passed in is
0446: * null
0447: * @exception MediaException thrown if the exception was thrown by the
0448: * MediaEntityLocal operation
0449: * @exception NamingException thrown if there are problems looking up the
0450: * MediaEntityLocalHome
0451: * @exception FinderException thrown if the primary key can not be found in
0452: * the datastore
0453: */
0454: public URL exportMediaEntity(String pk, URL loc)
0455: throws NamingException, FinderException, MediaException {
0456: if (pk == null)
0457: throw new NullPointerException(
0458: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0459: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0460: URL url = meb.exportMedia(loc);
0461: return url;
0462: }
0463:
0464: /**
0465: * Invokes getChildren() on the MediaEntityLocal The primary key passed will
0466: * first be resolved to a MediaEntityBean on which the operation should be
0467: * invoked on. The array of MediaEntityBean children will first be converted
0468: * into an array of primary keys representing the children before being
0469: * returned.
0470: *
0471: * @param pk - String representing the primary key of the MediaEntityBean to
0472: * invoke the operation on
0473: * @return String array of primary keys representing the children on the
0474: * MediaEntityBean
0475: * @exception NullPointerException - thrown if the primary key passed in is
0476: * null
0477: * @exception MediaException thrown if the exception was thrown by the
0478: * MediaEntityLocal operation
0479: * @exception NamingException thrown if there are problems looking up the
0480: * MediaEntityLocalHome
0481: * @exception FinderException thrown if the primary key can not be found in
0482: * the datastore
0483: */
0484: public String[] getMediaEntityChildren(String pk)
0485: throws NamingException, FinderException, MediaException {
0486: if (pk == null)
0487: throw new NullPointerException(
0488: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0489: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0490: MediaEntityLocal[] children = meb.getChildren();
0491: String[] childpks = new String[children.length];
0492: for (int i = 0; i < childpks.length; i++) {
0493: childpks[i] = (String) children[i].getPrimaryKey();
0494: }
0495: return childpks;
0496: }
0497:
0498: /**
0499: * Invokes getContent() on the MediaEntityLocal The primary key passed will
0500: * first be resolved to a MediaEntityBean on which the operation should be
0501: * invoked on.
0502: *
0503: * @param pk - String representing the primary key of the MediaEntityBean to
0504: * invoke the operation on
0505: * @return byte array of the MediaEntityBean's content
0506: * @exception NullPointerException - thrown if the primary key passed in is
0507: * null
0508: * @exception MediaException thrown if the exception was thrown by the
0509: * MediaEntityLocal operation
0510: * @exception NamingException thrown if there are problems looking up the
0511: * MediaEntityLocalHome
0512: * @exception FinderException thrown if the primary key can not be found in
0513: * the datastore
0514: */
0515: public byte[] getMediaEntityContent(String pk)
0516: throws NamingException, FinderException, MediaException {
0517: if (pk == null)
0518: throw new NullPointerException(
0519: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0520: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0521: return meb.getContent();
0522: }
0523:
0524: /**
0525: * Invokes getDescription() on the MediaEntityLocal The primary key passed
0526: * will first be resolved to a MediaEntityBean on which the operation should
0527: * be invoked on.
0528: *
0529: * @param pk - String representing the primary key of the MediaEntityBean to
0530: * invoke the operation on
0531: * @return String representing the description of the MediaEntityBean's
0532: * content
0533: * @exception NullPointerException - thrown if the primary key passed in is
0534: * null
0535: * @exception MediaException thrown if the exception was thrown by the
0536: * MediaEntityLocal operation
0537: * @exception NamingException thrown if there are problems looking up the
0538: * MediaEntityLocalHome
0539: * @exception FinderException thrown if the primary key can not be found in
0540: * the datastore
0541: */
0542: public String getMediaEntityDescription(String pk)
0543: throws NamingException, FinderException, MediaException {
0544: if (pk == null)
0545: throw new NullPointerException(
0546: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0547: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0548: return meb.getDescription();
0549: }
0550:
0551: /**
0552: * Invokes getFormat() on the MediaEntityLocal The primary key passed will
0553: * first be resolved to a MediaEntityBean on which the operation should be
0554: * invoked on.
0555: *
0556: * @param pk - String representing the primary key of the MediaEntityBean to
0557: * invoke the operation on
0558: * @return MediaFormat representing the MediaEntityBean's format
0559: * @exception NullPointerException - thrown if the primary key passed in is
0560: * null
0561: * @exception MediaException thrown if the exception was thrown by the
0562: * MediaEntityLocal operation
0563: * @exception NamingException thrown if there are problems looking up the
0564: * MediaEntityLocalHome
0565: * @exception FinderException thrown if the primary key can not be found in
0566: * the datastore
0567: */
0568: public MediaFormat getMediaEntityFormat(String pk)
0569: throws NamingException, FinderException, MediaException {
0570: if (pk == null)
0571: throw new NullPointerException(
0572: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0573: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0574: return meb.getFormat();
0575: }
0576:
0577: /**
0578: * Invokes getHeader() on the MediaEntityLocal The primary key passed will
0579: * first be resolved to a MediaEntityBean on which the operation should be
0580: * invoked on.
0581: *
0582: * @param pk - String representing the primary key of the MediaEntityBean to
0583: * invoke the operation on
0584: * @return MediaHeader representing the MediaEntityBean's header
0585: * @exception NullPointerException - thrown if the primary key passed in is
0586: * null
0587: * @exception MediaException thrown if the exception was thrown by the
0588: * MediaEntityLocal operation
0589: * @exception NamingException thrown if there are problems looking up the
0590: * MediaEntityLocalHome
0591: * @exception FinderException thrown if the primary key can not be found in
0592: * the datastore
0593: */
0594: public MediaHeader getMediaEntityHeader(String pk)
0595: throws NamingException, FinderException, MediaException {
0596: if (pk == null)
0597: throw new NullPointerException(
0598: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0599: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0600: return meb.getHeader();
0601: }
0602:
0603: /**
0604: * Invokes getLastModified() on the MediaEntityLocal The primary key passed
0605: * will first be resolved to a MediaEntityBean on which the operation should
0606: * be invoked on.
0607: *
0608: * @param pk - String representing the primary key of the MediaEntityBean to
0609: * invoke the operation on
0610: * @return long representing the timestamp of when MediaEntityBean was last
0611: * modified
0612: * @exception NullPointerException - thrown if the primary key passed in is
0613: * null
0614: * @exception MediaException thrown if the exception was thrown by the
0615: * MediaEntityLocal operation
0616: * @exception NamingException thrown if there are problems looking up the
0617: * MediaEntityLocalHome
0618: * @exception FinderException thrown if the primary key can not be found in
0619: * the datastore
0620: */
0621: public long getMediaEntityLastModified(String pk)
0622: throws NamingException, FinderException, MediaException {
0623: if (pk == null)
0624: throw new NullPointerException(
0625: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0626: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0627: return meb.getLastModified();
0628: }
0629:
0630: /**
0631: * Invokes getListeners() on the MediaEntityLocal The primary key passed
0632: * will first be resolved to a MediaEntityBean on which the operation should
0633: * be invoked on.
0634: *
0635: * @param pk - String representing the primary key of the MediaEntityBean to
0636: * invoke the operation on
0637: * @return MediaEntityListener array of the MediaEntityBean listeners
0638: * @exception NullPointerException - thrown if the primary key passed in is
0639: * null
0640: * @exception MediaException thrown if the exception was thrown by the
0641: * MediaEntityLocal operation
0642: * @exception NamingException thrown if there are problems looking up the
0643: * MediaEntityLocalHome
0644: * @exception FinderException thrown if the primary key can not be found in
0645: * the datastore
0646: */
0647: public MediaListener[] getMediaEntityListeners(String pk)
0648: throws NamingException, FinderException, MediaException {
0649: if (pk == null)
0650: throw new NullPointerException(
0651: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0652: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0653: return meb.getListeners();
0654: }
0655:
0656: /**
0657: * Invokes getLocation() on the MediaEntityLocal The primary key passed will
0658: * first be resolved to a MediaEntityBean on which the operation should be
0659: * invoked on.
0660: *
0661: * @param pk - String representing the primary key of the MediaEntityBean to
0662: * invoke the operation on
0663: * @return URL representing the location of the MediaEntityBean
0664: * @exception NullPointerException - thrown if the primary key passed in is
0665: * null
0666: * @exception MediaException thrown if the exception was thrown by the
0667: * MediaEntityLocal operation
0668: * @exception NamingException thrown if there are problems looking up the
0669: * MediaEntityLocalHome
0670: * @exception FinderException thrown if the primary key can not be found in
0671: * the datastore
0672: */
0673: public URL getMediaEntityLocation(String pk)
0674: throws NamingException, FinderException, MediaException {
0675: if (pk == null)
0676: throw new NullPointerException(
0677: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0678: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0679: return meb.getLocation();
0680: }
0681:
0682: /**
0683: * Invokes getMetaData() on the MediaEntityLocal The primary key passed will
0684: * first be resolved to a MediaEntityBean on which the operation should be
0685: * invoked on. The array of MetaDataEntityBean metadata will first be
0686: * converted into an array of primary keys representing the metadata before
0687: * being returned.
0688: *
0689: * @param pk - String representing the primary key of the MediaEntityBean to
0690: * invoke the operation on
0691: * @return String array of primary keys representing the MetaDataEntityBean
0692: * metadata on the MediaEntityBean
0693: * @exception NullPointerException - thrown if the primary key passed in is
0694: * null
0695: * @exception MediaException thrown if the exception was thrown by the
0696: * MediaEntityLocal operation
0697: * @exception NamingException thrown if there are problems looking up the
0698: * MediaEntityLocalHome or MetaDataEntityLocalHome
0699: * @exception FinderException thrown if the primary key can not be found in
0700: * the datastore
0701: */
0702: public String[] getMediaEntityMetaData(String pk)
0703: throws NamingException, FinderException, MediaException {
0704: if (pk == null)
0705: throw new NullPointerException(
0706: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0707: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0708: MetaDataEntityLocal[] metadata = meb.getMetaData();
0709: String[] mdpks = new String[metadata.length];
0710: for (int i = 0; i < mdpks.length; i++) {
0711: mdpks[i] = (String) metadata[i].getPrimaryKey();
0712: }
0713: return mdpks;
0714: }
0715:
0716: /**
0717: * Invokes getMimeType() on the MediaEntityLocal The primary key passed will
0718: * first be resolved to a MediaEntityBean on which the operation should be
0719: * invoked on.
0720: *
0721: * @param pk - String representing the primary key of the MediaEntityBean to
0722: * invoke the operation on
0723: * @return String representing the mimetype of the MediaEntityBean
0724: * @exception NullPointerException - thrown if the primary key passed in is
0725: * null
0726: * @exception MediaException thrown if the exception was thrown by the
0727: * MediaEntityLocal operation
0728: * @exception NamingException thrown if there are problems looking up the
0729: * MediaEntityLocalHome
0730: * @exception FinderException thrown if the primary key can not be found in
0731: * the datastore
0732: */
0733: public String getMediaEntityMimeType(String pk)
0734: throws NamingException, FinderException, MediaException {
0735: if (pk == null)
0736: throw new NullPointerException(
0737: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0738: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0739: return meb.getMimeType();
0740: }
0741:
0742: /**
0743: * Invokes getName() on the MediaEntityLocal The primary key passed will
0744: * first be resolved to a MediaEntityBean on which the operation should be
0745: * invoked on.
0746: *
0747: * @param pk - String representing the primary key of the MediaEntityBean to
0748: * invoke the operation on
0749: * @return String representing the name of the MediaEntityBean
0750: * @exception NullPointerException - thrown if the primary key passed in is
0751: * null
0752: * @exception MediaException thrown if the exception was thrown by the
0753: * MediaEntityLocal operation
0754: * @exception NamingException thrown if there are problems looking up the
0755: * MediaEntityLocalHome
0756: * @exception FinderException thrown if the primary key can not be found in
0757: * the datastore
0758: */
0759: public String getMediaEntityName(String pk) throws NamingException,
0760: FinderException, MediaException {
0761: if (pk == null)
0762: throw new NullPointerException(
0763: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0764: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0765: String name = meb.getName();
0766: return name;
0767: }
0768:
0769: /**
0770: * Invokes getNextVersion() on the MediaEntityLocal The primary key passed
0771: * will first be resolved to a MediaEntityBean on which the operation should
0772: * be invoked on. The primary key of the MediaEntityBean's next version
0773: * MediaEntityBean will be returned or null if the next version is null.
0774: *
0775: * @param pk - String representing the primary key of the MediaEntityBean to
0776: * invoke the operation on
0777: * @return String representing the primary key of the MediaEntityBean's next
0778: * version or null
0779: * @exception NullPointerException - thrown if the primary key passed in is
0780: * null
0781: * @exception MediaException thrown if the exception was thrown by the
0782: * MediaEntityLocal operation
0783: * @exception NamingException thrown if there are problems looking up the
0784: * MediaEntityLocalHome
0785: * @exception FinderException thrown if the primary key can not be found in
0786: * the datastore
0787: */
0788: public String getMediaEntityNextVersion(String pk)
0789: throws NamingException, FinderException, MediaException {
0790: if (pk == null)
0791: throw new NullPointerException(
0792: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0793: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0794: MediaEntityLocal nextmeb = meb.getNextVersion();
0795: if (nextmeb == null)
0796: return null;
0797: else
0798: return (String) nextmeb.getPrimaryKey();
0799: }
0800:
0801: /**
0802: * Invokes getParents() on the MediaEntityLocal The primary key passed will
0803: * first be resolved to a MediaEntityBean on which the operation should be
0804: * invoked on. The array of MediaEntityBean parents will first be converted
0805: * into an array of primary keys representing the parents before being
0806: * returned.
0807: *
0808: * @param pk - String representing the primary key of the MediaEntityBean to
0809: * invoke the operation on
0810: * @return String array of primary keys representing the parents on the
0811: * MediaEntityBean
0812: * @exception NullPointerException - thrown if the primary key passed in is
0813: * null
0814: * @exception MediaException thrown if the exception was thrown by the
0815: * MediaEntityLocal operation
0816: * @exception NamingException thrown if there are problems looking up the
0817: * MediaEntityLocalHome
0818: * @exception FinderException thrown if the primary key can not be found in
0819: * the datastore
0820: */
0821: public String[] getMediaEntityParents(String pk)
0822: throws NamingException, FinderException, MediaException {
0823: if (pk == null)
0824: throw new NullPointerException(
0825: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0826: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0827: MediaEntityLocal[] parents = meb.getParents();
0828: String[] parentpks = new String[parents.length];
0829: for (int i = 0; i < parentpks.length; i++) {
0830: parentpks[i] = (String) parents[i].getPrimaryKey();
0831: }
0832: return parentpks;
0833: }
0834:
0835: /**
0836: * Invokes getPreviousVersion() on the MediaEntityLocal The primary key
0837: * passed will first be resolved to a MediaEntityBean on which the operation
0838: * should be invoked on. The primary key of the MediaEntityBean's previous
0839: * version MediaEntityBean will be returned or null if the next version is
0840: * null.
0841: *
0842: * @param pk - String representing the primary key of the MediaEntityBean to
0843: * invoke the operation on
0844: * @return String representing the primary key of the MediaEntityBean's
0845: * previous version or null
0846: * @exception NullPointerException - thrown if the primary key passed in is
0847: * null
0848: * @exception MediaException thrown if the exception was thrown by the
0849: * MediaEntityLocal operation
0850: * @exception NamingException thrown if there are problems looking up the
0851: * MediaEntityLocalHome
0852: * @exception FinderException thrown if the primary key can not be found in
0853: * the datastore
0854: */
0855: public String getMediaEntityPreviousVersion(String pk)
0856: throws NamingException, FinderException, MediaException {
0857: if (pk == null)
0858: throw new NullPointerException(
0859: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0860: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0861: MediaEntityLocal prevmeb = meb.getPreviousVersion();
0862: if (prevmeb == null)
0863: return null;
0864: else
0865: return (String) prevmeb.getPrimaryKey();
0866: }
0867:
0868: /**
0869: * Invokes getProxy() on the MediaEntityLocal The primary key passed will
0870: * first be resolved to a MediaEntityBean on which the operation should be
0871: * invoked on.
0872: *
0873: * @param pk - String representing the primary key of the MediaEntityBean to
0874: * invoke the operation on
0875: * @return Media object representing the proxy of the MediaEntityBean
0876: * @exception NullPointerException - thrown if the primary key passed in is
0877: * null
0878: * @exception MediaException thrown if the exception was thrown by the
0879: * MediaEntityLocal operation
0880: * @exception NamingException thrown if there are problems looking up the
0881: * MediaEntityLocalHome
0882: * @exception FinderException thrown if the primary key can not be found in
0883: * the datastore
0884: */
0885: public Media getMediaEntityProxy(String pk) throws NamingException,
0886: FinderException, MediaException {
0887: if (pk == null)
0888: throw new NullPointerException(
0889: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0890: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0891: Media proxy = meb.getProxy();
0892: // TODO : fixed to work, depend on spec interpretation, getProxy return a Media and not mandatory a MediaBean
0893: if (proxy instanceof MediaEntityLocal) {
0894: proxy = new MediaBean(new ByteArrayInputStream(proxy
0895: .getContent()), proxy.getMimeType(), proxy
0896: .getName());
0897: }
0898: return proxy;
0899: }
0900:
0901: /**
0902: * Invokes getSize() on the MediaEntityLocal The primary key passed will
0903: * first be resolved to a MediaEntityBean on which the operation should be
0904: * invoked on.
0905: *
0906: * @param pk - String representing the primary key of the MediaEntityBean to
0907: * invoke the operation on
0908: * @return long size of the MediaEntityBean's content
0909: * @exception NullPointerException - thrown if the primary key passed in is
0910: * null
0911: * @exception MediaException thrown if the exception was thrown by the
0912: * MediaEntityLocal operation
0913: * @exception NamingException thrown if there are problems looking up the
0914: * MediaEntityLocalHome
0915: * @exception FinderException thrown if the primary key can not be found in
0916: * the datastore
0917: */
0918: public long getMediaEntitySize(String pk) throws NamingException,
0919: FinderException, MediaException {
0920: if (pk == null)
0921: throw new NullPointerException(
0922: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0923: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0924: return meb.getSize();
0925: }
0926:
0927: /**
0928: * Invokes importMedia(URL, String) on the MediaEntityLocal The primary key
0929: * passed will first be resolved to a MediaEntityBean on which the operation
0930: * should be invoked on.
0931: *
0932: * @param pk - String representing the primary key of the MediaEntityBean to
0933: * invoke the operation on
0934: * @param loc - URL representing the location of the source file to import
0935: * content from
0936: * @param name - String representing the optional name to be set on the
0937: * MediaEntityBean during the import
0938: * @exception NullPointerException - thrown if the primary key passed in is
0939: * null
0940: * @exception MediaException thrown if the exception was thrown by the
0941: * MediaEntityLocal operation
0942: * @exception NamingException thrown if there are problems looking up the
0943: * MediaEntityLocalHome
0944: * @exception FinderException thrown if the primary key can not be found in
0945: * the datastore
0946: */
0947: public void importMediaEntityContent(String pk, URL loc, String name)
0948: throws CreateException, NamingException, FinderException,
0949: MediaException {
0950: if (pk == null)
0951: throw new NullPointerException(
0952: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0953: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0954: meb.importMedia(loc, name);
0955: }
0956:
0957: /**
0958: * Invokes readContent(long, byte[]) on the MediaEntityLocal The primary key
0959: * passed will first be resolved to a MediaEntityBean on which the operation
0960: * should be invoked on.
0961: *
0962: * @param pk - String representing the primary key of the MediaEntityBean to
0963: * invoke the operation on
0964: * @param pos - long represeting the position to begin reading the content
0965: * from
0966: * @param buffer - byte array buffer to copy the media content into
0967: * beginning at offset 0
0968: * @return int representing the number of bytes read into the buffer
0969: * @exception NullPointerException - thrown if the primary key passed in is
0970: * null
0971: * @exception MediaException thrown if the exception was thrown by the
0972: * MediaEntityLocal operation
0973: * @exception NamingException thrown if there are problems looking up the
0974: * MediaEntityLocalHome
0975: * @exception FinderException thrown if the primary key can not be found in
0976: * the datastore
0977: */
0978: public int readMediaEntityContent(String pk, long pos, byte[] buffer)
0979: throws NamingException, FinderException, MediaException {
0980: if (pk == null)
0981: throw new NullPointerException(
0982: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
0983: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
0984: int size = meb.readContent(pos, buffer);
0985: System.out.println("size = " + size);
0986: System.out.println("buffer len = " + buffer.length);
0987: return size;
0988: }
0989:
0990: /**
0991: * Invokes readContent(long, byte[], int, int) on the MediaEntityLocal The
0992: * primary key passed will first be resolved to a MediaEntityBean on which
0993: * the operation should be invoked on.
0994: *
0995: * @param pk - String representing the primary key of the MediaEntityBean to
0996: * invoke the operation on
0997: * @param pos - long represeting the position to begin reading the content
0998: * from
0999: * @param buffer - byte array buffer to copy the media content into
1000: * beginning at specified offset
1001: * @param offset - int representing the offset in the buffer to begin
1002: * copying the media content from
1003: * @param length - int representing the max
1004: * @return int representing the number of bytes read into the buffer
1005: * @exception NullPointerException - thrown if the primary key passed in is
1006: * null
1007: * @exception MediaException thrown if the exception was thrown by the
1008: * MediaEntityLocal operation
1009: * @exception NamingException thrown if there are problems looking up the
1010: * MediaEntityLocalHome
1011: * @exception FinderException thrown if the primary key can not be found in
1012: * the datastore
1013: */
1014: public int readMediaEntityContent(String pk, long pos,
1015: byte[] buffer, int offset, int length)
1016: throws NamingException, FinderException, MediaException {
1017: if (pk == null)
1018: throw new NullPointerException(
1019: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1020: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1021: int size = meb.readContent(pos, buffer, offset, length);
1022: System.out.println("size = " + size);
1023: System.out.println("buffer len = " + buffer.length);
1024: return size;
1025: }
1026:
1027: /**
1028: * Invokes removeListener(MediaListener) on the MediaEntityLocal The primary
1029: * key passed will first be resolved to a MediaEntityBean on which the
1030: * operation should be invoked on.
1031: *
1032: * @param pk - String representing the primary key of the MediaEntityBean to
1033: * invoke the operation on
1034: * @param listener - MediaListener representing the listener to remove from
1035: * the MediaEntityBean
1036: * @exception NullPointerException - thrown if the primary key passed in is
1037: * null
1038: * @exception MediaException thrown if the exception was thrown by the
1039: * MediaEntityLocal operation
1040: * @exception NamingException thrown if there are problems looking up the
1041: * MediaEntityLocalHome
1042: * @exception FinderException thrown if the primary key can not be found in
1043: * the datastore
1044: */
1045: public void removeMediaEntityListener(String pk,
1046: MediaListener listener) throws MediaException,
1047: NamingException, FinderException {
1048: if (pk == null)
1049: throw new NullPointerException(
1050: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1051: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1052: meb.removeListener(listener);
1053: return;
1054: }
1055:
1056: /**
1057: * Invokes removeMetaData(MetaDataEntityLocal) on the MediaEntityLocal The
1058: * MEB primary key passed will first be resolved to a MediaEntityBean on
1059: * which the operation should be invoked on. If the MDEB primary key is not
1060: * null, it will be resolved to a MetaDataEntityBean before it is passed in
1061: * to the method. If the MDEB primary key is null, null is passed into the
1062: * remove operation.
1063: *
1064: * @param mebpk - String representing the primary key of the MediaEntityBean
1065: * to invoke the operation on
1066: * @param mdebpk - String representing the primary key of the
1067: * MetaDataEntityBean to remove
1068: * @exception NullPointerException - thrown if the primary key passed in is
1069: * null
1070: * @exception MediaException thrown if the exception was thrown by the
1071: * MediaEntityLocal operation
1072: * @exception NamingException thrown if there are problems looking up the
1073: * MediaEntityLocalHome or the MetaDataEntityLocalHome
1074: * @exception FinderException thrown if either primary keys can not be found
1075: * in the datastore
1076: */
1077: public void removeMediaEntityMetaData(String mebpk, String mdebpk)
1078: throws MediaException, NamingException, FinderException {
1079: if (mebpk == null)
1080: throw new NullPointerException(
1081: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1082: MediaEntityLocal meb = getMebHome().findByPrimaryKey(mebpk);
1083: MetaDataEntityLocal mdeb = null;
1084: if (mdebpk != null)
1085: mdeb = getMdebHome().findByPrimaryKey(mdebpk);
1086: meb.removeMetaData(mdeb);
1087: return;
1088: }
1089:
1090: /**
1091: * Invokes setChildren() on the MediaEntityLocal The primary key passed will
1092: * first be resolved to a MediaEntityBean on which the operation should be
1093: * invoked on. The array of MediaEntityBean primary keys representing the
1094: * children to be set will first be found in the datastore and converted to
1095: * an array of MediaEntityLocals before being passed in. If an element of
1096: * the primary key array is null, a coresponding null entry in the
1097: * MediaEntityLocal array will be set.
1098: *
1099: * @param pk - String representing the primary key of the MediaEntityBean to
1100: * invoke the operation on
1101: * @return String array of primary keys representing the children to be set
1102: * on the MediaEntityBean
1103: * @exception NullPointerException - thrown if the primary key passed in is
1104: * null
1105: * @exception MediaException thrown if the exception was thrown by the
1106: * MediaEntityLocal operation
1107: * @exception NamingException thrown if there are problems looking up the
1108: * MediaEntityLocalHome
1109: * @exception FinderException thrown if any of the primary keys can not be
1110: * found in the datastore
1111: */
1112: public void setMediaEntityChildren(String pk, String[] childpks)
1113: throws NamingException, FinderException, MediaException {
1114: if (pk == null)
1115: throw new NullPointerException(
1116: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1117: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1118: if (childpks != null) {
1119: MediaEntityLocal[] children = new MediaEntityLocal[childpks.length];
1120: for (int i = 0; i < children.length; i++) {
1121: if (childpks[i] == null)
1122: children[i] = null;
1123: else
1124: children[i] = getMebHome().findByPrimaryKey(
1125: childpks[i]);
1126: }
1127: meb.setChildren(children);
1128: } else
1129: meb.setChildren(null);
1130: }
1131:
1132: /**
1133: * Invokes setContent(byte[]) on the MediaEntityLocal The primary key passed
1134: * will first be resolved to a MediaEntityBean on which the operation should
1135: * be invoked on.
1136: *
1137: * @param pk - String representing the primary key of the MediaEntityBean to
1138: * invoke the operation on
1139: * @param content - byte array of content to be set on the MediaEntityBean
1140: * @exception NullPointerException - thrown if the primary key passed in is
1141: * null
1142: * @exception MediaException thrown if the exception was thrown by the
1143: * MediaEntityLocal operation
1144: * @exception NamingException thrown if there are problems looking up the
1145: * MediaEntityLocalHome
1146: * @exception FinderException thrown if the primary key can not be found in
1147: * the datastore
1148: */
1149: public void setMediaEntityContent(String pk, byte[] content)
1150: throws NamingException, FinderException, MediaException {
1151: if (pk == null)
1152: throw new NullPointerException(
1153: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1154: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1155: meb.setContent(content);
1156: }
1157:
1158: /**
1159: * Invokes setContent(InputStream) on the MediaEntityLocal The primary key
1160: * passed will first be resolved to a MediaEntityBean on which the operation
1161: * should be invoked on. Since an InputStream can not be passed over remote
1162: * boundaries, a File which represents the path to the content is passed and
1163: * is used to create a FileInputStream used to set the content.
1164: *
1165: * @param pk - String representing the primary key of the MediaEntityBean to
1166: * invoke the operation on
1167: * @param content - File that contains the content to be set on the
1168: * MediaEntityBean
1169: * @exception NullPointerException - thrown if the primary key passed in is
1170: * null
1171: * @exception MediaException thrown if the exception was thrown by the
1172: * MediaEntityLocal operation
1173: * @exception NamingException thrown if there are problems looking up the
1174: * MediaEntityLocalHome
1175: * @exception FinderException thrown if the primary key can not be found in
1176: * the datastore
1177: * @exception FileNotFoundException thrown if the File can not be located on
1178: * the filesystem
1179: */
1180: public void setMediaEntityContent(String pk, File content)
1181: throws NamingException, FinderException, MediaException,
1182: FileNotFoundException {
1183: if (pk == null)
1184: throw new NullPointerException(
1185: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1186: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1187: FileInputStream fin = new FileInputStream(content);
1188: meb.setContent(fin);
1189: }
1190:
1191: /**
1192: * Invokes setDescription(String) on the MediaEntityLocal The primary key
1193: * passed will first be resolved to a MediaEntityBean on which the operation
1194: * should be invoked on.
1195: *
1196: * @param pk - String representing the primary key of the MediaEntityBean to
1197: * invoke the operation on
1198: * @param desc - String representing the description of the
1199: * MediaEntityBean's content or null
1200: * @exception NullPointerException - thrown if the primary key passed in is
1201: * null
1202: * @exception MediaException thrown if the exception was thrown by the
1203: * MediaEntityLocal operation
1204: * @exception NamingException thrown if there are problems looking up the
1205: * MediaEntityLocalHome
1206: * @exception FinderException thrown if the primary key can not be found in
1207: * the datastore
1208: */
1209: public void setMediaEntityDescription(String pk, String desc)
1210: throws NamingException, FinderException, MediaException {
1211: if (pk == null)
1212: throw new NullPointerException(
1213: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1214: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1215: meb.setDescription(desc);
1216: }
1217:
1218: /**
1219: * Invokes setLocation(URL) on the MediaEntityLocal The primary key passed
1220: * will first be resolved to a MediaEntityBean on which the operation should
1221: * be invoked on.
1222: *
1223: * @param pk - String representing the primary key of the MediaEntityBean to
1224: * invoke the operation on
1225: * @param loc - URL representing the external location of the
1226: * MediaEntityBean content or null
1227: * @exception NullPointerException - thrown if the primary key passed in is
1228: * null
1229: * @exception MediaException thrown if the exception was thrown by the
1230: * MediaEntityLocal operation
1231: * @exception NamingException thrown if there are problems looking up the
1232: * MediaEntityLocalHome
1233: * @exception FinderException thrown if the primary key can not be found in
1234: * the datastore
1235: */
1236: public void setMediaEntityLocation(String pk, URL loc)
1237: throws NamingException, FinderException, MediaException {
1238: if (pk == null)
1239: throw new NullPointerException(
1240: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1241: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1242: meb.setLocation(loc);
1243: }
1244:
1245: /**
1246: * Invokes setMimeType(String) on the MediaEntityLocal The primary key
1247: * passed will first be resolved to a MediaEntityBean on which the operation
1248: * should be invoked on.
1249: *
1250: * @param pk - String representing the primary key of the MediaEntityBean to
1251: * invoke the operation on
1252: * @param mimeType - String representing the mimetype of the MediaEntityBean
1253: * @exception NullPointerException - thrown if the primary key passed in is
1254: * null
1255: * @exception MediaException thrown if the exception was thrown by the
1256: * MediaEntityLocal operation
1257: * @exception NamingException thrown if there are problems looking up the
1258: * MediaEntityLocalHome
1259: * @exception FinderException thrown if the primary key can not be found in
1260: * the datastore
1261: */
1262: public void setMediaEntityMimeType(String pk, String mimeType)
1263: throws NamingException, FinderException, MediaException {
1264: if (pk == null)
1265: throw new NullPointerException(
1266: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1267: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1268: meb.setMimeType(mimeType);
1269: }
1270:
1271: /**
1272: * Invokes setName() on the MediaEntityLocal The primary key passed will
1273: * first be resolved to a MediaEntityBean on which the operation should be
1274: * invoked on.
1275: *
1276: * @param pk - String representing the primary key of the MediaEntityBean to
1277: * invoke the operation on
1278: * @param name - String representing the name of the MediaEntityBean
1279: * @exception NullPointerException - thrown if the primary key passed in is
1280: * null
1281: * @exception MediaException thrown if the exception was thrown by the
1282: * MediaEntityLocal operation
1283: * @exception NamingException thrown if there are problems looking up the
1284: * MediaEntityLocalHome
1285: * @exception FinderException thrown if the primary key can not be found in
1286: * the datastore
1287: */
1288: public void setMediaEntityName(String pk, String name)
1289: throws NamingException, FinderException, MediaException {
1290: if (pk == null)
1291: throw new NullPointerException(
1292: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1293: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1294: meb.setName(name);
1295: }
1296:
1297: /**
1298: * Invokes setPreviousVersion(MediaEntityLocal) on the MediaEntityLocal The
1299: * primary key passed will first be resolved to a MediaEntityBean on which
1300: * the operation should be invoked on. The primary key passed representing
1301: * the MediaEntityBean's previous version MediaEntityBean will be located in
1302: * the datastore and resolved to a MediaEntityLocal before it is passed into
1303: * the setter. If the primary key representing the previous version is null
1304: * then null will be passed in.
1305: *
1306: * @param pk - String representing the primary key of the MediaEntityBean to
1307: * invoke the operation on
1308: * @param pvpk - String representing the primary key of the
1309: * MediaEntityBean's previous version or null
1310: * @exception NullPointerException - thrown if the primary key passed in is
1311: * null
1312: * @exception MediaException thrown if the exception was thrown by the
1313: * MediaEntityLocal operation
1314: * @exception NamingException thrown if there are problems looking up the
1315: * MediaEntityLocalHome
1316: * @exception FinderException thrown if the primary key can not be found in
1317: * the datastore
1318: */
1319: public void setMediaEntityPreviousVersion(String pk, String pvpk)
1320: throws NamingException, FinderException, MediaException {
1321: if (pk == null)
1322: throw new NullPointerException(
1323: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1324: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1325: MediaEntityLocal prevmeb = null;
1326: if (pvpk != null)
1327: prevmeb = getMebHome().findByPrimaryKey(pvpk);
1328: meb.setPreviousVersion(prevmeb);
1329: }
1330:
1331: /**
1332: * Invokes setProxy(MediaEntityLocal) on the MediaEntityLocal The primary
1333: * key passed will first be resolved to a MediaEntityBean on which the
1334: * operation should be invoked on. The primary key passed representing the
1335: * MediaEntityBean's proxy MediaEntityBean will be located in the datastore
1336: * and resolved to a MediaEntityLocal before it is passed into the setter.
1337: * If the primary key representing the proxy is null then null will be
1338: * passed in.
1339: *
1340: * @param pk - String representing the primary key of the MediaEntityBean to
1341: * invoke the operation on
1342: * @param proxypk - String representing the primary key of the proxy
1343: * MediaEntityBean
1344: * @exception NullPointerException - thrown if the primary key passed in is
1345: * null
1346: * @exception MediaException thrown if the exception was thrown by the
1347: * MediaEntityLocal operation
1348: * @exception NamingException thrown if there are problems looking up the
1349: * MediaEntityLocalHome
1350: * @exception FinderException thrown if the primary key can not be found in
1351: * the datastore
1352: */
1353: public void setMediaEntityProxy(String pk, String proxypk)
1354: throws NamingException, FinderException, MediaException {
1355: if (pk == null)
1356: throw new NullPointerException(
1357: "MEB Primary Key provided is null, please specify a non-null primary key for this operation");
1358: MediaEntityLocal meb = getMebHome().findByPrimaryKey(pk);
1359: MediaEntityLocal proxy = null;
1360: if (proxypk != null)
1361: proxy = getMebHome().findByPrimaryKey(proxypk);
1362: meb.setProxy(proxy);
1363: }
1364:
1365: /*
1366: * Helper Methods
1367: */
1368:
1369: private MediaEntityLocalHome getMebHome() throws NamingException {
1370: if (meb_home == null)
1371: meb_home = (MediaEntityLocalHome) getInitialContext()
1372: .lookup(MEBHOME_JNDI);
1373: return meb_home;
1374: }
1375:
1376: private MetaDataEntityLocalHome getMdebHome()
1377: throws NamingException {
1378: if (mdeb_home == null)
1379: mdeb_home = (MetaDataEntityLocalHome) getInitialContext()
1380: .lookup(MDEBHOME_JNDI);
1381: return mdeb_home;
1382: }
1383:
1384: private InitialContext getInitialContext() throws NamingException {
1385: if (ic == null)
1386: ic = new InitialContext();
1387: return ic;
1388: }
1389: }
|