[vlma-devel] commit: Fix an UnsupportedOperationException in MediaProgramAdd. ( Adrien Grand )
git version control
git at videolan.org
Wed Oct 29 21:14:04 CET 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed Oct 29 21:09:54 2008 +0100| [c08f78010c4c0c22e8b91ba9fdde199dde1b790f] | committer: Adrien Grand
Fix an UnsupportedOperationException in MediaProgramAdd.
Arrays.asList returns an array interpreted as a list (that's why the name is
asList and not toList) so trying to resize the result of this function throws
an UnsupportedOperationException.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=c08f78010c4c0c22e8b91ba9fdde199dde1b790f
---
.../vlma/web/media/MediaProgramAddController.java | 24 +++++++++++--------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java
index 2c2cdef..bcb5bb3 100644
--- a/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java
+++ b/vlma-webapp/src/main/java/org/videolan/vlma/web/media/MediaProgramAddController.java
@@ -22,9 +22,7 @@ package org.videolan.vlma.web.media;
import java.io.IOException;
import java.net.MalformedURLException;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
@@ -41,7 +39,7 @@ import org.videolan.vlma.model.Media;
import org.videolan.vlma.model.Program;
import org.videolan.vlma.model.SatChannel;
import org.videolan.vlma.model.StreamChannel;
-import org.videolan.vlma.model.StreamingStrategy;
+import org.videolan.vlma.model.StreamingStrategy.Protocol;
public class MediaProgramAddController extends SimpleFormController {
@@ -136,13 +134,19 @@ public class MediaProgramAddController extends SimpleFormController {
Media media = data.getMedia(mediaId);
/* Remove the VoD streaming strategy if the media is not a file channel */
- List<StreamingStrategy.Protocol> availableProtocols =
- Arrays.asList(StreamingStrategy.Protocol.values());
- if( media.getClass() != FilesChannel.class )
- availableProtocols.remove(StreamingStrategy.Protocol.VOD);
- mediasProgramAdd.setProtocols(
- (StreamingStrategy.Protocol[])availableProtocols.toArray(
- new StreamingStrategy.Protocol[availableProtocols.size()]));
+ Protocol[] protocols = Protocol.values();
+ Protocol[] availableProtocols;
+ if(media instanceof FilesChannel) {
+ availableProtocols = protocols;
+ } else {
+ availableProtocols = new Protocol[protocols.length - 1];
+ int i = 0;
+ for(Protocol protocol : protocols) {
+ if(protocol != Protocol.VOD)
+ availableProtocols[i++] = protocol;
+ }
+ }
+ mediasProgramAdd.setProtocols(availableProtocols);
Program program;
if (media.getProgram() == null) {
More information about the vlma-devel
mailing list