001: /*
002: * snapper
003: *
004: * Enhydra super-servlet presentation object
005: *
006: */
007:
008: package org.enhydra.snapperAdmin.presentation;
009:
010: import java.net.URLEncoder;
011:
012: import org.w3c.dom.html.*;
013: import org.w3c.dom.*;
014:
015: // Enhydra SuperServlet specification imports
016: import org.enhydra.snapper.SnapperManager;
017:
018: import org.enhydra.snapperAdmin.presentation.BasePO;
019: import org.enhydra.snapperAdmin.presentation.html.*;
020: import org.enhydra.snapperAdmin.spec.*;
021: import org.enhydra.xml.xmlc.XMLObject;
022:
023: public class NotIndexedPresentation extends BasePO {
024:
025: protected XMLObject getDOM() throws Exception {
026:
027: NotIndexedListHTML htmlPage;
028: NotIndexed[] niArray = null;
029: NotIndexed ni = null;
030: String siteName = "", siteId = "";
031:
032: htmlPage = (NotIndexedListHTML) comms.xmlcFactory
033: .create(NotIndexedListHTML.class);
034:
035: try {
036: siteName = comms.request.getParameter("name");
037: siteId = comms.request.getParameter("id");
038:
039: ni = NotIndexedFactory
040: .getNotIndexed("org.enhydra.snapperAdmin.business.NotIndexedImpl");
041:
042: niArray = ni.getListForID(siteName, siteId);
043:
044: } catch (Exception ex) {
045: System.out.println("Exception: " + ex);
046: }
047:
048: HTMLTableRowElement templateRow = htmlPage
049: .getElementTemplateRow();
050: htmlPage.setTextSiteName(siteName);
051:
052: HTMLElement fileLinkCellTemplate = htmlPage
053: .getElementFileLink();
054: templateRow.removeAttribute("id");
055: Node pathTable = templateRow.getParentNode();
056: String link;
057: if (niArray != null && niArray.length != 0) {
058: for (int num = 0; num < niArray.length; num++) {
059: try {
060: NotIndexed current = niArray[num];
061: String type = "";
062: try {
063: type = current.getPath().substring(
064: current.getPath().lastIndexOf(".") + 1,
065: current.getPath().lastIndexOf(".") + 4);
066: } catch (Exception e) {
067: type = "";
068: }
069: String linkOfFile = current.getPath();
070:
071: if (SnapperManager.getInstance()
072: .getFileSeparatorConvention() != null
073: && SnapperManager.getInstance()
074: .getFileSeparatorConvention()
075: .equalsIgnoreCase("unix")) {
076:
077: linkOfFile = linkOfFile.replaceAll("\\\\", "/");
078: }
079:
080: if (linkOfFile.indexOf("|") == -1) {
081: link = "DM_DownloadPO.po?url="
082: + URLEncoder
083: .encode(linkOfFile, "UTF-8")
084: + "&type=" + type + "&id=" + siteName;
085: } else {
086: link = "DM_DownloadPO.po?url="
087: + URLEncoder
088: .encode(
089: linkOfFile
090: .substring(
091: 0,
092: linkOfFile
093: .indexOf("|")),
094: "UTF-8") + "&type="
095: + type + "&id=" + siteName;
096: }
097:
098: htmlPage.getElementFileLink().setHref(link);
099:
100: htmlPage.setTextFileLink(linkOfFile);
101:
102: pathTable.appendChild(templateRow.cloneNode(true));
103:
104: }
105:
106: catch (Exception ex) {
107: ex.printStackTrace();
108: }
109: }
110: }
111:
112: templateRow.getParentNode().removeChild(templateRow);
113: return htmlPage;
114: }
115: }
|