1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package olr.presentation;
18
19 import java.util.Iterator;
20
21 import olr.rdf.OLR3Definitions;
22 import olr.rdf.Resource;
23 import olr.rdf.Tools;
24
25 import org.w3c.dom.Node;
26 import org.w3c.dom.html.HTMLAnchorElement;
27 import org.w3c.dom.html.HTMLElement;
28
29 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
30
31 /***
32 * @version $Id: ContentReaderHeader.java,v 1.6 2004/08/02 18:48:21 roku Exp $
33 */
34 public class ContentReaderHeader extends SecureHttpPresentation
35 {
36 /***
37 * Initializes an instance of this class.
38 */
39 public ContentReaderHeader()
40 {
41 }
42
43 public String handleDefault()
44 throws HttpPresentationException
45 {
46 return showPage();
47 }
48
49 public String showPage()
50 {
51 ContentReaderHeaderHTML page = new ContentReaderHeaderHTML();
52 try
53 {
54 HTMLAnchorElement belongsTo = page.getElementBelongsTo();
55 HTMLElement belongsToSep = page.getElementBelongsToSep();
56 Resource subject = getSessionData().getStatementPool().getResource(getAboutURI());
57 if(subject != null)
58 {
59 page.setTextTitle(subject.getTitle());
60 String urls = "";
61 for(Iterator it = subject.getObjects(OLR3Definitions.OLR3_SHOWLINK).iterator(); it.hasNext();)
62 urls = String.valueOf(urls) + String.valueOf(String.valueOf(urls.length() <= 0 ? "" : ", ") + String.valueOf(it.next().toString()));
63
64 page.setTextUrls(urls);
65 Node parent = belongsTo.getParentNode();
66 boolean isFirst = true;
67 for(Iterator it = subject.getObjects(OLR3Definitions.OLR3_BELONGSTO).iterator(); it.hasNext();)
68 {
69 String related = it.next().toString();
70 Resource relatedObj = getSessionData().getStatementPool().getResource(related);
71 belongsTo.getFirstChild().setNodeValue(relatedObj != null ? relatedObj.getTitle() : related);
72 belongsTo.setAttribute("href", "Content.po?aboutURI=".concat(String.valueOf(String.valueOf(Tools.URItoID(related)))));
73 if(!isFirst)
74 parent.appendChild(belongsToSep.cloneNode(true));
75 parent.appendChild(belongsTo.cloneNode(true));
76 isFirst = false;
77 }
78
79 parent.removeChild(belongsTo);
80 parent.removeChild(belongsToSep);
81 }
82 }
83 catch(Exception e)
84 {
85 e.printStackTrace();
86 }
87 return page.toDocument();
88 }
89
90 private String getAboutURI()
91 {
92 try
93 {
94 String aboutURI = getComms().request.getParameter("aboutURI");
95 if(aboutURI != null)
96 {
97 String s = Tools.IDtoURI(aboutURI);
98 return s;
99 }
100 }
101 catch(Exception e)
102 {
103 e.printStackTrace();
104 }
105 return null;
106 }
107 }