source: greenstone3/branches/customizingGreenstone3/src/java/org/greenstone/gsdl3/core/Page.java@ 14713

Last change on this file since 14713 was 14713, checked in by dnk2, 17 years ago

dump of existing code

File size: 3.9 KB
Line 
1package org.greenstone.gsdl3.core;
2
3import java.io.File;
4import java.util.HashMap;
5
6import org.greenstone.gsdl3.util.*;
7import org.w3c.dom.*;
8
9public class Page {
10
11 private Element page ;
12 private Element pageRequest ;
13 private Element pageResponse ;
14
15 private Document siteUi ;
16 private Document collectUi ;
17 private Document siteMetadata ;
18 private Document collectMetadata ;
19
20 private Receptionist receptionist ;
21
22 public Page(Element page, Receptionist receptionist) {
23 try {
24 this.page = page ;
25 this.receptionist = receptionist ;
26
27 pageRequest = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
28 pageResponse = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
29
30 String siteHome = GSFile.siteHome(GlobalProperties.getGSDL3Home(), getSite()) ;
31 String collection = getCollection() ;
32
33 File siteUiFile = new File(siteHome + File.separatorChar + "ui" + File.separatorChar + "ui.xml") ;
34 //System.out.println("siteUi: " + siteUiFile.getAbsolutePath()) ;
35 siteUi = receptionist.converter.getDOM(siteUiFile, "utf-8");
36 if (siteUi == null) {
37 System.out.println(" could not parse site level ui file: " + siteUiFile.getPath());
38 }
39
40 File siteMetadataFile = new File(siteHome + File.separatorChar + "metadata.xml") ;
41 //System.out.println("siteMetadata: " + siteMetadataFile.getAbsolutePath()) ;
42 siteMetadata = receptionist.converter.getDOM(siteMetadataFile, "utf-8");
43 if (siteMetadata == null) {
44 System.out.println(" could not parse site level metadata file: " + siteMetadataFile.getPath());
45 }
46
47 if (!collection.equals("")) {
48 File collectUiFile = new File(GSFile.collectionBaseDir(siteHome, collection) + File.separatorChar + "ui" + File.separatorChar + "ui.xml") ;
49 collectUi = receptionist.converter.getDOM(collectUiFile, "utf-8");
50 if (collectUi == null) {
51 System.out.println(" could not parse collect level ui file: " + collectUiFile.getPath());
52 }
53
54 File collectMetadataFile = new File(GSFile.collectionBaseDir(siteHome, collection) + File.separatorChar + "metadata.xml") ;
55 collectMetadata = receptionist.converter.getDOM(collectMetadataFile, "utf-8");
56 if (collectMetadata == null) {
57 System.out.println(" could not parse collect level metadata file: " + collectMetadataFile.getPath());
58 }
59 }
60 } catch (Exception e) {
61 e.printStackTrace() ;
62 }
63 }
64
65 public Element getPage() {
66 return page ;
67 }
68
69 public Element getPageRequest() {
70 return pageRequest ;
71 }
72
73 public Element getPageResponse() {
74 return pageResponse ;
75 }
76
77 public String getAction() {
78 return pageRequest.getAttribute("action") ;
79 }
80
81 public String getSubaction() {
82 return pageRequest.getAttribute("subaction") ;
83 }
84
85 public String getSiteHome() {
86 return GSFile.siteHome(GlobalProperties.getGSDL3Home(), getSite()) ;
87 }
88
89 public String getCollectionHome() {
90 String collection = this.getCollection() ;
91 if (!collection.equals(""))
92 return GSFile.collectionBaseDir(getSiteHome(), collection) ;
93 else
94 return null ;
95 }
96
97 public Document getSiteUi() {
98 return siteUi ;
99 }
100
101 public Document getCollectUi() {
102 return collectUi ;
103 }
104
105 public Document getSiteMetadata() {
106 return siteMetadata ;
107 }
108
109 public Document getCollectMetadata() {
110 return collectMetadata ;
111 }
112
113 public String getLanguage() {
114 String lang = pageRequest.getAttribute(GSXML.LANG_ATT);
115 return lang ;
116 }
117
118 public String getSite() {
119 return (String) receptionist.config_params.get(GSConstants.SITE_NAME) ;
120 }
121
122 public String getCollection() {
123 String collection = "" ;
124 Element request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
125
126 Element cgi_param_list = (Element)GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
127 if (cgi_param_list != null) {
128 HashMap params = GSXML.extractParams(cgi_param_list, false);
129 collection = (String)params.get(GSParams.COLLECTION);
130 if (collection == null) collection = "";
131 }
132 return collection ;
133 }
134}
Note: See TracBrowser for help on using the repository browser.