KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > media > urlcomposers > RamURLComposer


1 /*
2   
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5   
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8   
9 */

10
11 package org.mmbase.applications.media.urlcomposers;
12
13 import org.mmbase.module.core.*;
14 import org.mmbase.servlet.MMBaseServlet;
15 import org.mmbase.util.logging.*;
16 import org.mmbase.applications.media.Format;
17 import java.util.*;
18
19
20 /**
21  * Provides the functionality to create URL's (or URI's) for a certain
22  * fragment, source, provider combination.
23  *
24  * Depends on mediafragment.ram.jsp and mediafragment.asf.jsp in the
25  * templates dir. These can be mapped to something else in
26  * web.xml. The servlet name must be media-asf and media-rm then.
27  *
28  * @author Michiel Meeuwissen
29  * @author Rob Vermeulen (VPRO)
30  * @since MMBase-1.7
31  * @see Config
32  */

33 public class RamURLComposer extends FragmentURLComposer { // also for wmp/asx
34
private static final Logger log = Logging.getLoggerInstance(RamURLComposer.class);
35     
36     protected Format format;
37     
38     public void init(MMObjectNode provider, MMObjectNode source, MMObjectNode fragment, Map info, Set cacheExpireObjects) {
39         super.init(provider, source, fragment, info, cacheExpireObjects);
40         format = Format.get(source.getIntValue("format"));
41     }
42     
43     protected StringBuffer JavaDoc getURLBuffer() {
44         List servlets = MMBaseServlet.getServletMappings("media-" + format);
45         String JavaDoc servlet;
46         if (servlets == null || servlets.size() == 0) {
47             log.error("No mapping found to media-" + format + " servlet. Change this in your web.xml");
48             servlet = Config.templatesDir + "mediafragment." + format + ".jsp";
49         } else {
50             String JavaDoc root = MMBaseContext.getHtmlRootUrlPath();
51             root = root.substring(0, root.length() - 1);
52             servlet = root + (String JavaDoc) servlets.get(0);
53         }
54         
55         return new StringBuffer JavaDoc("http://" + Config.host + servlet + "?fragment=" + (fragment == null ? "" : "" + fragment.getNumber()) + "&source=" + (source == null ? "" : "" + source.getNumber()));
56
57     }
58
59     public Format getFormat() {
60         if (format == Format.RM) return Format.RAM;
61         if (format == Format.ASF) return Format.WMP;
62         return format;
63     }
64
65 }
66
Popular Tags