--- /dev/null
+package mircoders.media;
+
+import mir.entity.Entity;
+import mir.media.MediaExc;
+import mir.media.MediaFailure;
+import mir.media.MediaHandler;
+import mir.session.UploadedFile;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>URLMediaHandler</p>
+ * <p>Description:
+ * This is a media handler for externally stored media.
+ * The media is presented by its url.
+ * </p>
+ * @author Zapata
+ */
+
+public class URLMediaHandler implements MediaHandler {
+ private String bigIcon;
+ private String tinyIcon;
+ private String iconAlternative;
+
+ public URLMediaHandler(String aBigIcon, String aTinyIcon, String anIconAlternative) {
+ bigIcon = aBigIcon;
+ tinyIcon = aTinyIcon;
+ iconAlternative = anIconAlternative;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Since this media handler assumes the media is stored on a wholly different
+ * server, this operation is not applicable
+ */
+ public void store(UploadedFile anUploadedFile, Entity aMedia, Entity aMediaType) throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Since this media handler assumes the media is stored on a wholly different
+ * server, this operation is not applicable
+ */
+ public void store(InputStream anInputStream, Entity anEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Since this media handler assumes the media is stored on a wholly different
+ * server, this operation is not applicable
+ */
+ public void store(File aFile, Entity aMedia, Entity aMediaType) throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void produce(Entity anEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ // nothing to do here
+ }
+
+ public InputStream getMedia(Entity anEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ return null;
+ }
+
+ public InputStream getThumbnail(Entity anEntity) throws MediaExc, MediaFailure {
+ return null;
+ }
+
+ public String getThumbnailMimeType(Entity aMediaEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ return "application/octetstream";
+ }
+
+ public List getURL(Entity aMediaEntity, Entity aMediaTypeEntity) throws MediaExc, MediaFailure {
+ List result = new ArrayList();
+ result.add(aMediaTypeEntity.getFieldValue("publish_server")+aMediaTypeEntity.getFieldValue("publish_path"));
+
+ return result;
+ }
+
+ public Object getURLs(Entity ent, Entity mediaTypeEnt) throws MediaExc, MediaFailure {
+ return null;
+ }
+
+ public String getStoragePath () throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getIconStoragePath () throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getPublishHost () throws MediaExc, MediaFailure {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getBigIconName () {
+ return bigIcon;
+ }
+
+ public String getTinyIconName () {
+ return tinyIcon;
+ }
+
+ public String getIconAltName () {
+ return iconAlternative;
+ }
+
+ public String getDescr(Entity mediaTypeEnt) {
+ return "Url";
+ }
+}
\ No newline at end of file