0001: /*
0002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
0003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
0004: */
0005:
0006: /*
0007: * NTEViewBean.java
0008: */
0009:
0010: package com.sun.portal.search.admin;
0011:
0012: import java.io.*;
0013: import java.lang.reflect.*;
0014: import java.lang.*;
0015: import java.net.*;
0016: import java.util.*;
0017: import java.util.logging.Logger;
0018: import java.util.logging.Level;
0019: import javax.servlet.*;
0020: import javax.servlet.http.*;
0021: import com.iplanet.jato.*;
0022: import com.iplanet.jato.model.*;
0023: import com.iplanet.jato.util.*;
0024: import com.iplanet.jato.view.*;
0025: import com.iplanet.jato.view.event.*;
0026: import com.iplanet.jato.view.html.*;
0027:
0028: import com.sun.portal.search.util.SearchConfig;
0029: import com.sun.portal.search.rdm.RDMTaxonomy;
0030: import com.sun.portal.search.rdm.RDMClassification;
0031: import com.sun.portal.search.admin.model.TaxonomyTreeModel;
0032: import com.sun.portal.log.common.PortalLogger;
0033:
0034: import com.iplanet.am.console.components.view.html.MessageBox;
0035: import com.iplanet.am.console.components.view.html.IPlanetButton;
0036:
0037: /**
0038: *
0039: */
0040: public class NTEViewBean extends CSViewBeanBase implements
0041: WebActionHandler, RequestHandler, RequestCompletionListener {
0042: //////////////////////////////////////
0043: // Class variables
0044: //////////////////////////////////////
0045:
0046: public static final String PAGE_NAME = "NTE";
0047: public static final String DEFAULT_DISPLAY_URL = "/ps/searchadmin/NTE.jsp";
0048: public static final String DISPLAY_PAGE = "page";
0049: public static final String DISPLAY_NB_NODES = "nbNodes";
0050:
0051: // banner elements
0052: public static final String CHILD_EXPAND_ALL = "ExpandAll";
0053: public static final String CHILD_COLLAPSE_ALL = "CollapseAll";
0054: public static final String CHILD_PREVIOUS = "PreviousLink";
0055: public static final String CHILD_NEXT = "NextLink";
0056: public static final String CHILD_PAGE_SELECT = "PageSelect";
0057: public static final String CHILD_NODES_PER_PAGE = "NodesPerPage";
0058: public static final String CHILD_CATEGORY_EDITOR = "NCE";
0059: public static final String CHILD_CATEGORY_PATH = "catPath";
0060: public static final String CHILD_ERROR_MSG_BOX = "errorMsgBox";
0061: public static final String CHILD_WARNING_MSG_BOX = "warningMsgBox";
0062: public static final String CHILD_JUMP_PAGE_URL = "jumpPageUrl";
0063: public static final String CHILD_NEW_NB_NODES_URL = "changeNbNodesUrl";
0064: public static final String CHILD_PAGE_NB_NODES_URL = "targetPageNbNodesUrl";
0065: public static final String CHILD_TAX_SAVE = "TaxSave";
0066: public static final String CHILD_TAX_RESET = "TaxReset";
0067: public static final String CHILD_TAX_REINDEX = "TaxReindex";
0068:
0069: // tree elements
0070: public static final String CHILD_TREEVIEW1 = "NTTView";
0071:
0072: // action types
0073: public static final String TAX_ACTION_SAVE = "save";
0074: public static final String TAX_ACTION_RESET = "reset";
0075: public static final String TAX_ACTION_CANCEL = "Cancel";
0076: public static final String TAX_ACTION_ADD_CHILD = "add_child";
0077: public static final String TAX_ACTION_ADD_SIBLING = "add_sibling";
0078: public static final String TAX_ACTION_UPDATE = "update";
0079: public static final String TAX_ACTION_DELETE = "delete";
0080: public static final String TAX_ACTION_EDIT = "edit";
0081: public static final String TAX_ACTION_ERROR = "editingError";
0082: public static final String TAX_ACTION_TIMESTAMP = "editTimeStamp";
0083: public static final String TAX_PERSIST_ERROR = "persistError";
0084: public static final String TAX_PERSIST_WARNING = "persistWarning";
0085: private static final String DEF_MAX_DISPLAYED_NODE = "50";
0086:
0087: public static int maxNbNodesDisplayed;
0088: public static int maxNbComboElement;
0089: public int currentPage = 1;
0090: public int nbPages = 1;
0091: public int nbDisplayable = -1;
0092: public int nbParents = -1;
0093: protected String nodePage;
0094: private int intervalSize;
0095: private static String[] nodesPerPageLabels;
0096: private static String[] nodesPerPageValues;
0097: private int editedCategory = -1;
0098:
0099: // Create a Logger for this class
0100: private static Logger debugLogger = PortalLogger
0101: .getLogger(NTEViewBean.class);
0102:
0103: static {
0104: try {
0105: // init of the pagination related attributes
0106: String maxComboStr = SearchConfig
0107: .getValue(SearchConfig.CATEGORY_MAX_COMBO_ELEMENT);
0108: if (maxComboStr != null) {
0109: maxNbComboElement = Integer.parseInt(maxComboStr);
0110: } else {
0111: maxNbComboElement = 10;
0112: }
0113: String maxNodeDisplayedStr = SearchConfig
0114: .getValue(SearchConfig.CATEGORY_ELEMENTS_PER_PAGE);
0115: if (maxNodeDisplayedStr != null) {
0116: StringTokenizer st = new StringTokenizer(
0117: maxNodeDisplayedStr, ",");
0118: if (st.countTokens() < 1) {
0119: // a single value to DEF_MAX_DISPLAYED_NODE
0120: nodesPerPageLabels = new String[] { DEF_MAX_DISPLAYED_NODE };
0121: nodesPerPageValues = new String[] { DEF_MAX_DISPLAYED_NODE };
0122: } else {
0123: nodesPerPageLabels = new String[st.countTokens()];
0124: nodesPerPageValues = new String[st.countTokens()];
0125: boolean hasAll = false;
0126: int ndx = 0;
0127: String labelStr;
0128: String valueStr;
0129: while (st.hasMoreTokens()) {
0130: String token = (String) st.nextToken();
0131: int value = Integer.parseInt(token);
0132: if ((value <= 0)) {
0133: // add "all" only if not present already
0134: labelStr = "all";
0135: valueStr = "-1";
0136: if (!hasAll) {
0137: // add the couple Label/Value
0138: nodesPerPageLabels[ndx] = labelStr;
0139: nodesPerPageValues[ndx] = valueStr;
0140: if (value <= 0) {
0141: hasAll = true;
0142: }
0143: }
0144: } else {
0145: nodesPerPageLabels[ndx] = token;
0146: nodesPerPageValues[ndx] = token;
0147: }
0148: ndx++;
0149: }
0150: }
0151: maxNbNodesDisplayed = Integer
0152: .parseInt(nodesPerPageValues[0]);
0153: } else {
0154: maxNbNodesDisplayed = 25;
0155: }
0156: } catch (NumberFormatException nfe) {
0157:
0158: debugLogger.log(Level.INFO, "PSSH_CSPSA0060",
0159: SearchConfig.CATEGORY_ELEMENTS_PER_PAGE);
0160: maxNbNodesDisplayed = -1;
0161: maxNbComboElement = 10;
0162: }
0163: }
0164:
0165: /**
0166: * Creates new NTEViewBean
0167: */
0168: public NTEViewBean() {
0169: super (PAGE_NAME);
0170: try {
0171: setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
0172: registerChildren();
0173: } catch (Exception e) {
0174: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
0175: .getMessage());
0176: }
0177: }
0178:
0179: /**
0180: *
0181: */
0182: protected void registerChildren() {
0183: try {
0184: registerChild(CHILD_TREEVIEW1, NTTView.class);
0185: registerChild(CHILD_PREVIOUS, HREF.class);
0186: registerChild(CHILD_EXPAND_ALL, IPlanetButton.class);
0187: registerChild(CHILD_COLLAPSE_ALL, IPlanetButton.class);
0188: registerChild(CHILD_NEXT, HREF.class);
0189: registerChild(CHILD_PAGE_SELECT, ComboBox.class);
0190: registerChild(CHILD_NODES_PER_PAGE, ComboBox.class);
0191: registerChild(CHILD_CATEGORY_EDITOR, NCEView.class);
0192: registerChild(CHILD_CATEGORY_PATH, CategoryPathView.class);
0193: registerChild(CHILD_TAX_SAVE, IPlanetButton.class);
0194: registerChild(CHILD_TAX_RESET, IPlanetButton.class);
0195: registerChild(CHILD_TAX_REINDEX, IPlanetButton.class);
0196: registerChild(CHILD_ERROR_MSG_BOX, MessageBox.class);
0197: registerChild(CHILD_WARNING_MSG_BOX, MessageBox.class);
0198: registerChild(CHILD_JUMP_PAGE_URL, StaticTextField.class);
0199: registerChild(CHILD_NEW_NB_NODES_URL, StaticTextField.class);
0200: registerChild(CHILD_PAGE_NB_NODES_URL,
0201: StaticTextField.class);
0202: } catch (Exception e) {
0203: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
0204: .getMessage());
0205: }
0206: }
0207:
0208: /**
0209: *
0210: */
0211: protected View createChild(String name) {
0212: try {
0213: View Headerchild = super .createChild(name);
0214: if (Headerchild != null) {
0215: return Headerchild;
0216: }
0217:
0218: View child = null;
0219: if (name.equals(CHILD_CATEGORY_EDITOR)) {
0220: child = new NCEView(this , CHILD_CATEGORY_EDITOR);
0221: return child;
0222: }
0223: if (name.equals(CHILD_TREEVIEW1)) {
0224: child = new NTTView(this , CHILD_TREEVIEW1);
0225: return child;
0226: }
0227: // CHILD_TAX_EXPAND_ALL
0228: if (name.equals(CHILD_EXPAND_ALL)) {
0229: child = new IPlanetButton(this , CHILD_EXPAND_ALL, "");
0230: if (getTaxonomyTreeModel().nChildren(
0231: RDMTaxonomy.RDM_TAXONOMY_ROOT) > 0) {
0232: ((IPlanetButton) child).setEnable(true);
0233: } else {
0234: ((IPlanetButton) child).setEnable(false);
0235: }
0236: return child;
0237: }
0238: // CHILD_TAX_COLLAPSE_ALL
0239: if (name.equals(CHILD_COLLAPSE_ALL)) {
0240: child = new IPlanetButton(this , CHILD_COLLAPSE_ALL, "");
0241: if (getTaxonomyTreeModel().nChildren(
0242: RDMTaxonomy.RDM_TAXONOMY_ROOT) > 0) {
0243: ((IPlanetButton) child).setEnable(true);
0244: } else {
0245: ((IPlanetButton) child).setEnable(false);
0246: }
0247: return child;
0248: }
0249: if (name.equals(CHILD_PREVIOUS)) {
0250: child = new HREF(this , CHILD_PREVIOUS, "");
0251: return child;
0252: }
0253: if (name.equals(CHILD_NEXT)) {
0254: child = new HREF(this , CHILD_NEXT, "");
0255: return child;
0256: }
0257: if (name.equals(CHILD_CATEGORY_PATH)) {
0258: child = new CategoryPathView(this , CHILD_CATEGORY_PATH);
0259: return child;
0260: }
0261: // CHILD_TAX_SAVE
0262: if (name.equals(CHILD_TAX_SAVE)) {
0263: child = new IPlanetButton(this , CHILD_TAX_SAVE, "");
0264: if (getTaxonomyTreeModel().getModifiedState()) {
0265: ((IPlanetButton) child).setEnable(true);
0266: } else {
0267: ((IPlanetButton) child).setEnable(false);
0268: }
0269: return child;
0270: }
0271: // CHILD_TAX_RESET
0272: if (name.equals(CHILD_TAX_RESET)) {
0273: child = new IPlanetButton(this , CHILD_TAX_RESET, "");
0274: if (getTaxonomyTreeModel().getModifiedState()
0275: || getTaxonomyTreeModel().isConfigNewer()
0276: || (getTaxonomyTreeModel().getErrorMsg() != null)) {
0277: ((IPlanetButton) child).setEnable(true);
0278: } else {
0279: ((IPlanetButton) child).setEnable(false);
0280: }
0281: return child;
0282: }
0283: if (name.equals(CHILD_TAX_REINDEX)) {
0284: return new IPlanetButton(this , CHILD_TAX_REINDEX, "");
0285: }
0286: if (name.equals(CHILD_ERROR_MSG_BOX)) {
0287: child = new MessageBox(this , CHILD_ERROR_MSG_BOX, "");
0288: return child;
0289: }
0290: if (name.equals(CHILD_WARNING_MSG_BOX)) {
0291: child = new MessageBox(this , CHILD_WARNING_MSG_BOX, "");
0292: return child;
0293: }
0294: if (name.equals(CHILD_NEW_NB_NODES_URL)) {
0295: // URL format is : ps/searchadmin/NTE?nbNodes=
0296: StringBuffer sb = new StringBuffer(getModuleURL()
0297: .toString());
0298: sb.append("/");
0299: sb.append(getQualifiedName().toString());
0300: sb.append('?');
0301: sb.append(DISPLAY_NB_NODES);
0302: sb.append("=");
0303: child = new StaticTextField(this ,
0304: CHILD_NEW_NB_NODES_URL, sb.toString());
0305:
0306: return child;
0307: }
0308: if (name.equals(CHILD_PAGE_NB_NODES_URL)) {
0309: child = new StaticTextField(this ,
0310: CHILD_PAGE_NB_NODES_URL, "");
0311: return child;
0312: }
0313: if (name.equals(CHILD_JUMP_PAGE_URL)) {
0314: // URL format is : ps/searchadmin/NTE?page=
0315: StringBuffer sb = new StringBuffer(getModuleURL()
0316: .toString());
0317: sb.append("/");
0318: sb.append(getQualifiedName().toString());
0319: sb.append("?");
0320: sb.append(DISPLAY_PAGE);
0321: sb.append("=");
0322: child = new StaticTextField(this , CHILD_JUMP_PAGE_URL,
0323: sb.toString());
0324: return child;
0325: }
0326: if (name.equals(CHILD_NODES_PER_PAGE)) {
0327: child = new ComboBox(this , CHILD_NODES_PER_PAGE, "");
0328: OptionList nodesPerPageOptions = new OptionList(
0329: nodesPerPageLabels, nodesPerPageValues);
0330: ((ComboBox) child).setOptions(nodesPerPageOptions);
0331: return child;
0332: }
0333: if (name.equals(CHILD_PAGE_SELECT)) {
0334: child = new ComboBox(this , CHILD_PAGE_SELECT, "");
0335: return child;
0336: }
0337: debugLogger.log(Level.FINER, "PSSH_CSPSA0048", name);
0338: if (name != null) {
0339: throw new IllegalArgumentException(
0340: "Invalid child name [" + name + "]");
0341: } else {
0342: throw new IllegalArgumentException(
0343: "Invalid child name [<NULL>]");
0344: }
0345: } catch (Exception e) {
0346: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
0347: .getMessage());
0348: if (name != null) {
0349: throw new IllegalArgumentException(
0350: "Invalid child name [" + name + "]");
0351: } else {
0352: throw new IllegalArgumentException(
0353: "Invalid child name [<NULL>]");
0354: }
0355: }
0356: }
0357:
0358: public void beginDisplay(DisplayEvent event) {
0359: // setting page encoding
0360: setPageEncoding();
0361:
0362: setDisplayFieldValue(CHILD_TAX_REINDEX,
0363: getLocalizedString("category.edit.btn_reindex"));
0364: setDisplayFieldValue(CHILD_EXPAND_ALL,
0365: getLocalizedString("category.edit.btn_expand_all"));
0366: setDisplayFieldValue(CHILD_COLLAPSE_ALL,
0367: getLocalizedString("category.edit.btn_collapse_all"));
0368: setDisplayFieldValue(CHILD_TAX_SAVE,
0369: getLocalizedString("category.edit.btn_save"));
0370: setDisplayFieldValue(CHILD_TAX_RESET,
0371: getLocalizedString("category.edit.btn_reset"));
0372:
0373: // counting the number of expanded (displayable nodes
0374: getNbDisplayable();
0375:
0376: // get the number of pages
0377: getNbPages();
0378:
0379: // get currentPage
0380: getCurrentPage();
0381:
0382: // set the pageSelect dropdown
0383: setPageSelect();
0384:
0385: // updating the current number of nodes displayed per page
0386: setDisplayFieldValue(CHILD_NODES_PER_PAGE, String
0387: .valueOf(maxNbNodesDisplayed));
0388:
0389: // put the selected Category if it's in the request
0390: RequestContext rc = getRequestContext();
0391: HttpServletRequest req = rc.getRequest();
0392:
0393: // is in edition mode?
0394: String editedCategoryStr;
0395: // pick up selected id from query string
0396: editedCategoryStr = (String) req
0397: .getParameter(NTEViewBean.TAX_ACTION_EDIT);
0398: if (editedCategoryStr != null) {
0399: try {
0400: editedCategory = Integer.parseInt(editedCategoryStr);
0401: } catch (NumberFormatException nfe) {
0402: debugLogger.log(Level.INFO, "PSSH_CSPSA0062",
0403: editedCategoryStr);
0404: editedCategory = -1;
0405: }
0406: }
0407:
0408: // checking for error message
0409: String errorMsg = getErrorMsg();
0410: MessageBox errorMsgBox = (MessageBox) getChild(CHILD_ERROR_MSG_BOX);
0411: if (errorMsg != null) {
0412: errorMsgBox.setType(MessageBox.TYPE_ERROR);
0413: errorMsgBox.setMessage(errorMsg.toString());
0414: errorMsgBox.setEnabled(true);
0415: } else {
0416: errorMsgBox.setEnabled(false);
0417: }
0418: // checking for warning messages
0419: MessageBox warningMsgBox = (MessageBox) getChild(CHILD_WARNING_MSG_BOX);
0420: StringBuffer warningMsg = new StringBuffer();
0421: if (getTaxonomyTreeModel().getModifiedState()) {
0422: warningMsg
0423: .append(getLocalizedString("category.edit.save-modifications"));
0424: Date lastUserActionDate = (Date) getPageSessionAttribute(TAX_ACTION_TIMESTAMP);
0425: if (lastUserActionDate != null
0426: && ((TaxonomyTreeModel) getTaxonomyTreeModel())
0427: .getLastActionDate().after(
0428: lastUserActionDate)) {
0429: warningMsg
0430: .append(getLocalizedString("category.edit.warning.concurrent_editing"));
0431: }
0432: }
0433: try {
0434: if (getTaxonomyTreeModel().isConfigNewer()) {
0435: // if there is already a warning about the model being modified
0436: if (warningMsg.length() != 0) {
0437: warningMsg.append("<HR>");
0438: }
0439: warningMsg
0440: .append(getLocalizedString("category.edit.warning.newer_config"));
0441: warningMsg.append("<BR>");
0442: warningMsg
0443: .append(getLocalizedString("category.edit.warning.newer_config_action"));
0444: }
0445: } catch (ModelControlException mce) {
0446: warningMsg.append("\n");
0447: warningMsg.append(mce.getMessage());
0448: }
0449: if (warningMsg != null) {
0450: if (warningMsg.length() != 0) {
0451: warningMsgBox.setType(MessageBox.TYPE_WARNING);
0452: warningMsgBox.setMessage(warningMsg.toString());
0453: warningMsgBox.setEnabled(true);
0454: } else {
0455: warningMsgBox.setEnabled(false);
0456: }
0457: } else {
0458: warningMsgBox.setEnabled(false);
0459: }
0460: }
0461:
0462: /*
0463: *
0464: */
0465: public String getErrorMsg() {
0466: try {
0467: StringBuffer errMsg = new StringBuffer();
0468: // get model errors
0469: String modelErr = (String) getTaxonomyTreeModel()
0470: .getErrorMsg();
0471: if (modelErr != null) {
0472: errMsg.append(modelErr);
0473: }
0474: if (errMsg.length() != 0) {
0475: return (errMsg.toString());
0476: } else {
0477: return null;
0478: }
0479: } catch (Exception e) {
0480: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
0481: .getMessage());
0482: return "A system error occured but cannot identify the source";
0483: }
0484: }
0485:
0486: /*
0487: * finds among the displayable nodes the NodeId of the one index is passed on
0488: */
0489: String findDisplayableNodeId(int displayableNodeIndex) {
0490: return String.valueOf(displayableNodeIndex); //TODO really search for it
0491: }
0492:
0493: /*
0494: * finds the index of the displayable node which nodeId is passed on
0495: */
0496: int findDisplayableNodeIndex(String NodeId) {
0497: //TODO not used for now, but might be needed if we want to search for the
0498: // taxonomy Id (String) given it's index in the displayable list
0499: return 0;
0500: }
0501:
0502: /*
0503: * return true if there is a need of navigation or if
0504: * we currently display All, to allow reduction of the nbNodes per page
0505: */
0506: public boolean beginNavigationBarDisplay(ChildDisplayEvent event) {
0507: boolean ret = false;
0508: // determining the interval between displayable node to form the
0509: // combobox menu that enables jumping directly to specific page
0510: // labeled by a node
0511: if (beginBrowseModeDisplay(event)
0512: && (beginPageSelectDisplay(event) || beginNodesPerPageDisplay(event))) {
0513: // dont display the comboBox
0514: ret = true;
0515: } else {
0516: ret = false;
0517: }
0518: return ret;
0519: }
0520:
0521: /*
0522: * set the comboBox option list if pages > 1
0523: * set the current Page accordingly if possible
0524: */
0525: public boolean beginPageSelectDisplay(ChildDisplayEvent event) {
0526: boolean ret = false;
0527:
0528: // determining the interval between displayable node to form the
0529: // combobox menu that enables jumping directly to specific page
0530: // labeled by a node
0531: if (beginBrowseModeDisplay(event)
0532: && (beginPreviousLinkDisplay(event) || beginNextLinkDisplay(event))) {
0533: // dont display the comboBox
0534: ret = true;
0535: } else {
0536: ret = false;
0537: }
0538: return ret;
0539: }
0540:
0541: /*
0542: * set the comboBox option list if more than one choice in search.conf
0543: * for attribute admin-category_editor_nodes_per_page
0544: */
0545: public boolean beginNodesPerPageDisplay(ChildDisplayEvent event) {
0546: boolean ret = false;
0547: // determining the interval between displayable node to form the
0548: // combobox menu that enables jumping directly to specific page
0549: // labeled by a node
0550: if (nodesPerPageLabels.length > 1
0551: && beginBrowseModeDisplay(event)) {
0552: ret = true;
0553: } else {
0554: // dont display the comboBox nor it's label
0555: ret = false;
0556: }
0557: return ret;
0558: }
0559:
0560: /*
0561: * do not diplays the page select label and drop down
0562: */
0563: public boolean beginNotPageSelectDisplay(ChildDisplayEvent event) {
0564: return !beginPageSelectDisplay(event);
0565: }
0566:
0567: /*
0568: * displaying the Previous link
0569: */
0570: public boolean beginPreviousLinkDisplay(ChildDisplayEvent event) {
0571: boolean ret = false;
0572:
0573: if (nbPages > 1 && beginBrowseModeDisplay(event)) {
0574: if (isFirstDisplayed()) {
0575: ret = false;
0576: } else {
0577: ret = true;
0578: }
0579: } else {
0580: ret = false;
0581: }
0582: return ret;
0583: }
0584:
0585: /*
0586: * displaying the Previous link
0587: */
0588: public boolean beginNextLinkDisplay(ChildDisplayEvent event) {
0589: boolean ret = false;
0590:
0591: if (nbPages > 1 && beginBrowseModeDisplay(event)) {
0592: if (isLastDisplayed()) {
0593: ret = false;
0594: } else {
0595: ret = true;
0596: }
0597: } else {
0598: ret = false;
0599: }
0600: return ret;
0601: }
0602:
0603: /*
0604: * not displaying the previous link
0605: */
0606: public boolean beginNotPreviousLinkDisplay(ChildDisplayEvent event) {
0607: return !beginPreviousLinkDisplay(event);
0608: }
0609:
0610: /*
0611: * not displaying the previous link
0612: */
0613: public boolean beginNotNextLinkDisplay(ChildDisplayEvent event) {
0614: return !beginNextLinkDisplay(event);
0615: }
0616:
0617: /*
0618: * is in edition mode?
0619: */
0620: public boolean beginBrowseModeDisplay(ChildDisplayEvent event) {
0621:
0622: if (editedCategory == -1)
0623: return true;
0624: else
0625: return false;
0626: }
0627:
0628: /*
0629: * is in edition mode?
0630: */
0631: public boolean beginEditModeDisplay(ChildDisplayEvent event) {
0632: return !beginBrowseModeDisplay(event);
0633: }
0634:
0635: /*
0636: * expandAll
0637: */
0638: public void handleExpandAllRequest(RequestInvocationEvent event) {
0639: expandAll();
0640:
0641: // refresh
0642: RequestContext rc = getRequestContext();
0643: HttpServletResponse resp = rc.getResponse();
0644: StringBuffer sb = new StringBuffer(PAGE_NAME
0645: + "?gx_charset=UTF-8&" + DISPLAY_PAGE + "="
0646: + currentPage);
0647: try {
0648: resp.sendRedirect(sb.toString());
0649: } catch (Exception e) {
0650: debugLogger.log(Level.INFO, "PSSH_CSPSA0063", e
0651: .getMessage());
0652: }
0653:
0654: }
0655:
0656: /*
0657: * collapseAll
0658: */
0659: public void handleCollapseAllRequest(RequestInvocationEvent event) {
0660: collapseAll();
0661: // refresh
0662: RequestContext rc = getRequestContext();
0663: HttpServletResponse resp = rc.getResponse();
0664: StringBuffer sb = new StringBuffer(PAGE_NAME
0665: + "?gx_charset=UTF-8&" + DISPLAY_PAGE + "=" + 1);
0666: try {
0667: resp.sendRedirect(sb.toString());
0668: } catch (Exception e) {
0669: debugLogger.log(Level.INFO, "PSSH_CSPSA0063", e
0670: .getMessage());
0671: }
0672: }
0673:
0674: //////////////////////////////////////
0675: // utilities
0676: //////////////////////////////////////
0677:
0678: /*
0679: * expands/collapse the tree node from a given start point
0680: */
0681: public void expand(String nodeID, boolean state) {
0682:
0683: try {
0684: TreeView tv = (TreeView) getChild(CHILD_TREEVIEW1);
0685: TreeViewStateData sd = tv.getStateData();
0686: sd.setNodeExpanded(TaxonomyTreeModel.hashNodeId(nodeID),
0687: state);
0688: ArrayList descendance = getTaxonomyTreeModel()
0689: .getDescendance(nodeID);
0690: if (descendance != null) {
0691: if (!descendance.isEmpty()) {
0692: Iterator i = descendance.iterator();
0693: while (i.hasNext()) {
0694: sd.setNodeExpanded(TaxonomyTreeModel
0695: .hashNodeId((String) i.next()), state);
0696: }
0697: String descendanceStr = descendance.toString();
0698: }
0699: }
0700: } catch (Exception e) {
0701: debugLogger.log(Level.INFO, "PSSH_CSPSA0064", new String[] {
0702: nodeID, Boolean.toString(state), e.getMessage() });
0703: }
0704: }
0705:
0706: /*
0707: * expands the entire tree from ROOT to tow
0708: */
0709: public void expandAll() {
0710: expand(getTaxonomyTreeModel().getRoot().getId(), true);
0711: }
0712:
0713: /*
0714: * collapses the entire tree to the ROOT
0715: */
0716: public void collapseAll() {
0717: try {
0718: expand(getTaxonomyTreeModel().getRoot().getId(), false);
0719: } catch (Exception e) {
0720: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
0721: .getMessage());
0722: }
0723: }
0724:
0725: /*
0726: * returns the taxonomyName
0727: */
0728: public String getTaxonomyName() {
0729: try {
0730: return getTaxonomyTreeModel().getNodeName(
0731: RDMTaxonomy.RDM_TAXONOMY_ROOT);
0732: } catch (ModelControlException e) {
0733: // return the default taxonomy name out of the seach.config
0734: String defaultTaxonomyName = SearchConfig
0735: .getValue(SearchConfig.TAX);
0736: if (defaultTaxonomyName.trim().length() == 0) {
0737: return RDMTaxonomy.RDM_TAXONOMY_ROOT;
0738: } else {
0739: return defaultTaxonomyName;
0740: }
0741: }
0742: }
0743:
0744: /*
0745: * getting the tree Model
0746: */
0747: public TaxonomyTreeModel getTaxonomyTreeModel() {
0748: try {
0749: ServletContext sc = getRequestContext().getServletContext();
0750: Locale locale = getUserLocale();
0751:
0752: // adding locale as part of attribute key, so user with same locale shares the same model */
0753: TaxonomyTreeModel model = (TaxonomyTreeModel) sc
0754: .getAttribute(TaxonomyTreeModel.MODEL_NAME + "."
0755: + locale.toString());
0756: if (model == null) {
0757: // instanciate the model and put it in the Servlet Context
0758: model = new TaxonomyTreeModel();
0759: model.userLocale = locale;
0760: sc.setAttribute(TaxonomyTreeModel.MODEL_NAME + "."
0761: + locale.toString(), model);
0762: }
0763: return model;
0764: } catch (Exception e) {
0765: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
0766: .getMessage());
0767: return null;
0768: }
0769: }
0770:
0771: /*
0772: * check if first node displayed in current page
0773: */
0774: public boolean isFirstDisplayed() {
0775: boolean ret = true;
0776: if (currentPage == 1) {
0777: ret = true;
0778: } else {
0779: ret = false;
0780: }
0781: return ret;
0782: }
0783:
0784: /*
0785: * check if last node displayed in current page
0786: */
0787: public boolean isLastDisplayed() {
0788: boolean ret = true;
0789: if (currentPage >= (nbDisplayable - maxNbNodesDisplayed + 1)) {
0790: // adding 1 because the Root nodes need to be accounted
0791: ret = true;
0792: } else {
0793: ret = false;
0794: }
0795: return ret;
0796: }
0797:
0798: /*
0799: * retrieving from model and TreeViewStateData number of diplayable node
0800: * 2. recursive call dor getNbDisplayable(aParentNode)
0801: */
0802: public void getNbDisplayable() {
0803: nbDisplayable = 0;
0804: nbParents = 0;
0805: // recusively accumulate displayable children of ROOT
0806: nbDisplayable += getNbDisplayable(RDMTaxonomy.RDM_TAXONOMY_ROOT);
0807:
0808: // setting the number of nodes per page fromrequest if any
0809: RequestContext rc = getRequestContext();
0810: HttpServletRequest req = rc.getRequest();
0811:
0812: String nodesPerPageStr = (String) req
0813: .getParameter(DISPLAY_NB_NODES);
0814: if (nodesPerPageStr != null) {
0815: try {
0816: // parse parameter
0817: int nodesPerPage = Integer.parseInt(nodesPerPageStr);
0818: // check validity [-1,++[
0819: if (nodesPerPage < -1) {
0820: //forcing to -1 all nodes in 1 page
0821: nodesPerPage = nbDisplayable;
0822: }
0823: maxNbNodesDisplayed = nodesPerPage;
0824: } catch (Exception e) {
0825: // no change
0826: debugLogger.log(Level.INFO, "PSSH_CSPSA0065",
0827: new String[] { DISPLAY_NB_NODES,
0828: nodesPerPageStr,
0829: String.valueOf(maxNbNodesDisplayed) });
0830: }
0831: }
0832: }
0833:
0834: public int getNbDisplayable(String startNodeId) {
0835: nbDisplayable = 0; // root always displayable;
0836: try {
0837: TreeView tv = (TreeView) getChild(CHILD_TREEVIEW1);
0838: TreeViewStateData sd = tv.getStateData();
0839: // if node is a parent
0840: if (getTaxonomyTreeModel().isParentNode(startNodeId)) {
0841: nbParents++;
0842: // if parentNode expanded
0843: if (sd.isNodeExpanded(TaxonomyTreeModel
0844: .hashNodeId(startNodeId))) {
0845: // accumulate the number of displayable for all children
0846: ArrayList children = (ArrayList) getTaxonomyTreeModel()
0847: .getChildren(startNodeId);
0848: Iterator c = children.iterator();
0849: RDMClassification childNode;
0850: String childNodeId;
0851: while (c.hasNext()) {
0852: childNode = (RDMClassification) c.next();
0853: childNodeId = childNode.getId();
0854: nbDisplayable += getNbDisplayable(childNodeId);
0855: }
0856: nbDisplayable += 1; // adding the parent
0857: } else {
0858: nbDisplayable = 1;
0859: }
0860: } else {
0861: // not a parent return 1
0862: nbDisplayable = 1;
0863: }
0864:
0865: return nbDisplayable;
0866: } catch (Exception e) {
0867: debugLogger.log(Level.INFO, "PSSH_CSPSA0061", new String[] {
0868: startNodeId, e.getMessage() });
0869: return 0;
0870: }
0871: }
0872:
0873: /*
0874: * returns the nodeId for a given linearized index.
0875: * catches the CategoryName thrown by findNodeId(int, int, String)
0876: * else returns the TaxonomyName.
0877: */
0878: public String findNodeId(int index) {
0879: try {
0880: findNodeId(index, 0, RDMTaxonomy.RDM_TAXONOMY_ROOT);
0881: return getTaxonomyName();
0882: } catch (ModelControlException mce) {
0883: // found the nodeId which linearized index is nodeIndex
0884: return mce.getMessage();
0885: }
0886: }
0887:
0888: /*
0889: * go recursily through the treeStateData till counted the "nodeIndex"
0890: * displayable node, at which point through an exception which message is
0891: * the String representation of the Node which linearise index is nodeIndex
0892: * if no exception, that mean count down not finished, and method return
0893: * current index count, for using it as start point for next call
0894: */
0895: public int findNodeId(int nodeIndex, int currentIndex,
0896: String startNodeId) throws ModelControlException {
0897: int ret = currentIndex + 1;
0898: if (ret == nodeIndex) {
0899: // found the node in question
0900: if (nodeIndex == 1) {
0901: // this is the taxonomy node
0902: throw new ModelControlException(getTaxonomyName());
0903: } else {
0904: // regular category Node
0905: throw new ModelControlException(startNodeId);
0906: }
0907: } else {
0908: // not yet reach the node, continue drillng down
0909: try {
0910: TreeView tv = (TreeView) getChild(CHILD_TREEVIEW1);
0911: TreeViewStateData sd = tv.getStateData();
0912: if (getTaxonomyTreeModel().isParentNode(startNodeId)) {
0913: // if parentNode expanded
0914: if (sd.isNodeExpanded(TaxonomyTreeModel
0915: .hashNodeId(startNodeId))) {
0916: // search nodeId within children
0917: ArrayList children = (ArrayList) getTaxonomyTreeModel()
0918: .getChildren(startNodeId);
0919: Iterator c = children.iterator();
0920: RDMClassification childNode;
0921: String childNodeId;
0922: while (c.hasNext()) {
0923: childNode = (RDMClassification) c.next();
0924: childNodeId = childNode.getId();
0925: ret = findNodeId(nodeIndex, ret,
0926: childNodeId);
0927: }
0928: } else {
0929: // not expanded parent node, also not node Indexed search for
0930: }
0931: } else {
0932: // leaf node, if it was the one, would already have handle it
0933: }
0934: return ret;
0935: } catch (NullPointerException e) {
0936: throw new ModelControlException(getTaxonomyName());
0937: }
0938: }
0939: }
0940:
0941: /*
0942: * returns the linearized index of the nodeId
0943: * every parent and leaf node that is displayable prior to the argument
0944: * nodeId is accounted for including itself.
0945: * nodes that might be displayable but that would appear down the "nodeId"
0946: * are skipped all together
0947: */
0948: public int findNodePage(String nodeId) {
0949: int page = 0;
0950: if (nodeId != null) {
0951: if (nodeId.equals(RDMTaxonomy.RDM_TAXONOMY_ROOT)) {
0952: page = 1;
0953: } else {
0954: // recusively accumulate displayable children of ROOT
0955: page += findNodePage(nodeId,
0956: RDMTaxonomy.RDM_TAXONOMY_ROOT);
0957: }
0958: } else {
0959: page = 1;
0960: }
0961: return page;
0962: }
0963:
0964: /*
0965: *
0966: */
0967: public int findNodePage(String nodeId, String startNodeId) {
0968: int nbNodes = 0; // root always displayable;
0969: try {
0970: // count the startNodeId if before or the searched nodeId
0971: if ((startNodeId.compareTo(nodeId) <= 0)
0972: || (startNodeId
0973: .equals(RDMTaxonomy.RDM_TAXONOMY_ROOT))) {
0974: TreeView tv = (TreeView) getChild(CHILD_TREEVIEW1);
0975: TreeViewStateData sd = tv.getStateData();
0976: // if node is a parent
0977: if (getTaxonomyTreeModel().isParentNode(startNodeId)) {
0978: // if parentNode expanded
0979: if (sd.isNodeExpanded(TaxonomyTreeModel
0980: .hashNodeId(startNodeId))) {
0981: // accumulate the number of displayable for all children
0982: ArrayList children = (ArrayList) getTaxonomyTreeModel()
0983: .getChildren(startNodeId);
0984: Iterator c = children.iterator();
0985: RDMClassification childNode;
0986: String childNodeId;
0987: while (c.hasNext()) {
0988: childNode = (RDMClassification) c.next();
0989: childNodeId = childNode.getId();
0990: int nbNodesInChild = findNodePage(nodeId,
0991: childNodeId);
0992: nbNodes += nbNodesInChild;
0993: }
0994: nbNodes += 1; // adding the parent
0995: } else {
0996: nbNodes = 1;
0997: }
0998: } else {
0999: nbNodes = 1;
1000: }
1001: } else {
1002: nbNodes = 0;
1003: }
1004: return nbNodes;
1005: } catch (Exception e) {
1006: debugLogger.log(Level.INFO, "PSSH_CSPSA0055", new String[] {
1007: nodeId, startNodeId, e.getMessage() });
1008: return 0;
1009: }
1010: }
1011:
1012: /*
1013: * get the total number of pages
1014: */
1015: public void getNbPages() {
1016: // calculate nbPages do add in the pageSelection option drop down
1017: if ((maxNbNodesDisplayed != 0)
1018: && ((nbDisplayable != -1) && (maxNbNodesDisplayed != -1))) {
1019: // caculate the number of pages (add 1 if division not full)
1020: nbPages = (new Double(StrictMath
1021: .ceil((double) nbDisplayable
1022: / (double) maxNbNodesDisplayed)))
1023: .intValue();
1024: } else {
1025: // displays all in one page
1026: nbPages = 1;
1027: }
1028: }
1029:
1030: /*
1031: * create dropDown list of page navigation
1032: */
1033: public void setPageSelect() {
1034:
1035: // Populating the Page drop down combobox
1036: OptionList pageOptions = new OptionList();
1037: if (nbPages > maxNbComboElement) {
1038: try {
1039: nbPages = maxNbComboElement;
1040: intervalSize = nbDisplayable / nbPages;
1041: } catch (Exception e) {
1042: // force to display all in one page
1043: nbPages = 1;
1044: intervalSize = nbDisplayable;
1045: }
1046: } else {
1047: intervalSize = maxNbNodesDisplayed;
1048: }
1049:
1050: // creating the dropdown list of pages
1051: // boolean shiftInsert = false;
1052: int targetPage;
1053: String targetPageStr;
1054: for (int i = 0, j = 0; i < nbPages; i++) {
1055: // check if time to add currentPage
1056: if ((currentPage > ((i - 1) * intervalSize))
1057: && (currentPage < (i * intervalSize))) {
1058: targetPageStr = String.valueOf(currentPage);
1059: //pageOptions.add(new Option(targetPageStr, targetPageStr));
1060: pageOptions.add(new Option(
1061: prettyPrintCategory(findNodeId(currentPage)),
1062: targetPageStr));
1063: //shiftInsert = true;
1064: }
1065: /*
1066: if (shiftInsert) {
1067: // the index of label from now on, is shifted in array, because of
1068: // the insertion of currentPage
1069: j=i+1;
1070: } else {
1071: j=i;
1072: }
1073: */
1074: // rounding the targetPage to a multiple of 5, (for cosmetic sakes)
1075: targetPage = ((i * intervalSize) / 5) * 5;
1076: if (targetPage == 0)
1077: targetPage = 1;
1078: if (targetPage != currentPage) {
1079: targetPageStr = String.valueOf(targetPage);
1080: // pageOptions.add(new Option(targetPageStr, targetPageStr));
1081: pageOptions.add(new Option(
1082: prettyPrintCategory(findNodeId(targetPage)),
1083: targetPageStr));
1084: }
1085: }
1086: if (currentPage > ((nbPages - 1) * intervalSize)) {
1087: // add the pageSelect option at the end after last interval
1088: targetPageStr = String.valueOf(currentPage);
1089: pageOptions.add(new Option(
1090: prettyPrintCategory(findNodeId(currentPage)),
1091: targetPageStr));
1092: }
1093: // updating the dropdown JATO combobox field
1094: try {
1095: ((ComboBox) getChild(CHILD_PAGE_SELECT))
1096: .setOptions(pageOptions);
1097: setDisplayFieldValue(CHILD_PAGE_SELECT, String
1098: .valueOf(currentPage));
1099: setDisplayFieldValue(CHILD_PAGE_NB_NODES_URL, String
1100: .valueOf(currentPage));
1101: } catch (Exception e) {
1102: debugLogger.log(Level.INFO, "PSSH_CSPSA0068", e
1103: .getMessage());
1104: }
1105: }
1106:
1107: /*
1108: * determines the page to be displayed
1109: * this depends on
1110: * - DISPLAY_PAGE : specifically giving the page number to display
1111: * this is passed on upon page selection or click on next/previous btns
1112: */
1113: public void getCurrentPage() {
1114: RequestContext rc = getRequestContext();
1115: HttpServletRequest req = rc.getRequest();
1116:
1117: // get the 1st page to display from
1118: try {
1119: // put the selected Category if it's in the request
1120: nodePage = (String) req.getParameter(DISPLAY_PAGE);
1121: // browsing mode
1122: // get the currentPage from DISPLAY_PAGE
1123: if (nodePage != null) {
1124: // this is in the case we come from a click on a node link
1125: currentPage = Integer.parseInt(nodePage);
1126: if (currentPage < 1)
1127: currentPage = 1;
1128: if (currentPage > (nbDisplayable - maxNbNodesDisplayed))
1129: currentPage = nbDisplayable - maxNbNodesDisplayed
1130: + 1;
1131: } else {
1132: currentPage = ((Integer) getPageSessionAttribute(DISPLAY_PAGE))
1133: .intValue();
1134: }
1135: currentPage = (currentPage < 1) ? 1 : currentPage;
1136: currentPage = (currentPage > nbPages * maxNbNodesDisplayed) ? nbPages
1137: : currentPage;
1138: } catch (NullPointerException npe) {
1139: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", npe
1140: .getMessage());
1141: currentPage = 1;
1142: }
1143:
1144: setPageSessionAttribute(DISPLAY_PAGE, new Integer(currentPage));
1145:
1146: }
1147:
1148: /*
1149: *
1150: */
1151: public int getPrevious() {
1152: int ret;
1153: try {
1154: currentPage = ((Integer) getPageSessionAttribute(DISPLAY_PAGE))
1155: .intValue();
1156: } catch (NullPointerException npe) {
1157: currentPage = 1;
1158: }
1159: if (currentPage > maxNbNodesDisplayed) {
1160: ret = currentPage - maxNbNodesDisplayed;
1161: } else {
1162: ret = 1;
1163: }
1164: clearPageSessionAttributes();
1165: return ret;
1166: }
1167:
1168: /*
1169: *
1170: */
1171: public int getNext() {
1172: int ret;
1173: try {
1174: currentPage = ((Integer) getPageSessionAttribute(DISPLAY_PAGE))
1175: .intValue();
1176: } catch (NullPointerException npe) {
1177: currentPage = 1;
1178: }
1179: if ((currentPage != -1)
1180: || (currentPage < (nbDisplayable - maxNbNodesDisplayed))) {
1181: ret = currentPage + maxNbNodesDisplayed;
1182: } else {
1183: ret = nbPages * intervalSize;
1184: }
1185: clearPageSessionAttributes();
1186: return ret;
1187: }
1188:
1189: //////////////////////////////////////
1190: // Event handling methods
1191: //////////////////////////////////////
1192:
1193: /**
1194: *
1195: */
1196: public void handleNextLinkRequest(RequestInvocationEvent event)
1197: throws ModelControlException {
1198: try {
1199: // refresh the category editor this time should
1200: // display the CategoryEditor "jato:content"
1201: RequestContext rc = event.getRequestContext();
1202: HttpServletResponse resp = rc.getResponse();
1203: StringBuffer sb = new StringBuffer(PAGE_NAME
1204: + "?gx_charset=UTF-8&" + DISPLAY_PAGE + "="
1205: + getNext());
1206: resp.sendRedirect(sb.toString());
1207: } catch (Exception e) {
1208: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
1209: .getMessage());
1210: throw new ModelControlException(
1211: "failed to handle click on next page link "
1212: + e.getMessage());
1213: }
1214: }
1215:
1216: /**
1217: *
1218: */
1219: public void handlePreviousLinkRequest(RequestInvocationEvent event)
1220: throws ModelControlException {
1221: try {
1222: // refresh the category editor this time should
1223: // display the CategoryEditor "jato:content"
1224: RequestContext rc = event.getRequestContext();
1225: HttpServletResponse resp = rc.getResponse();
1226: StringBuffer sb = new StringBuffer(PAGE_NAME
1227: + "?gx_charset=UTF-8&" + DISPLAY_PAGE + "="
1228: + getPrevious());
1229: resp.sendRedirect(sb.toString());
1230: } catch (Exception e) {
1231: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
1232: .getMessage());
1233: throw new ModelControlException(
1234: "failed to handle click on previous page link "
1235: + e.getMessage());
1236: }
1237: }
1238:
1239: public boolean beginExpandCollapseDisplay(ChildDisplayEvent event) {
1240: // TODO elaborate the code here
1241: return true;
1242: }
1243:
1244: /*
1245: * returns true if modifications where made to the tree
1246: */
1247: public boolean beginPersistanceMsgDisplay(ChildDisplayEvent event) {
1248: try {
1249: if ((getErrorMsg() != null)
1250: || (getTaxonomyTreeModel().getModifiedState())
1251: || (getTaxonomyTreeModel().isConfigNewer())) {
1252: return true;
1253: } else {
1254: return false;
1255: }
1256: } catch (Exception e) {
1257: debugLogger.log(Level.INFO, "PSSH_CSPSA0010", e
1258: .getMessage());
1259: return false;
1260: }
1261: }
1262:
1263: /*
1264: * Save action
1265: */
1266: public void handleTaxSaveRequest(RequestInvocationEvent event) {
1267: try {
1268: handleAction(event, TAX_ACTION_SAVE);
1269: } catch (Exception e) {
1270: debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
1271: event.toString(), e.getMessage() });
1272: }
1273: }
1274:
1275: /*
1276: * Reset action
1277: */
1278: public void handleTaxResetRequest(RequestInvocationEvent event) {
1279: try {
1280: handleAction(event, TAX_ACTION_RESET);
1281: } catch (Exception e) {
1282: debugLogger.log(Level.INFO, "PSSH_CSPSA0058", new String[] {
1283: event.toString(), e.getMessage() });
1284: }
1285: }
1286:
1287: /*
1288: * Rindex action
1289: */
1290: public void handleTaxReindexRequest(RequestInvocationEvent event) {
1291: try {
1292: RequestContext rc = event.getRequestContext();
1293: HttpServletResponse resp = rc.getResponse();
1294: resp.sendRedirect("Reindex");
1295: } catch (Exception e) {
1296: }
1297: }
1298:
1299: private void handleAction(RequestInvocationEvent event,
1300: String formAction) {
1301: String warningMsg = null;
1302: String errorMsg = null;
1303: try {
1304: RequestContext rc = event.getRequestContext();
1305: if ((formAction != null) && (!formAction.trim().equals(""))) {
1306: try {
1307: if (formAction.equals(TAX_ACTION_SAVE)) {
1308: // saving the Taxonomy to the config file
1309: TaxonomyTreeModel tmpTaxModel = getTaxonomyTreeModel();
1310: getTaxonomyTreeModel().save();
1311: } else if (formAction.equals(TAX_ACTION_RESET)) {
1312: // Resetting the Taxonomy from the config file
1313: getTaxonomyTreeModel().load();
1314: }
1315: // get the potential model persistance error
1316: errorMsg = getErrorMsg();
1317: } catch (Exception e) {
1318: debugLogger
1319: .log(Level.INFO, "PSSH_CSPSA0061",
1320: new String[] { formAction,
1321: e.getMessage() });
1322: errorMsg = getLocalizedString("category.edit.error.default");
1323: }
1324: } else {
1325: debugLogger.log(Level.FINER, "PSSH_CSPSA0053",
1326: formAction);
1327: }
1328: StringBuffer sb = new StringBuffer(PAGE_NAME
1329: + "?gx_charset=UTF-8&" + DISPLAY_PAGE + "="
1330: + currentPage);
1331: HttpServletResponse resp = rc.getResponse();
1332: resp.sendRedirect(sb.toString());
1333:
1334: } catch (Exception e) {
1335: debugLogger.log(Level.INFO, "PSSH_CSPSA0055", new String[] {
1336: event.toString(), formAction, e.getMessage() });
1337: }
1338: }
1339:
1340: ////////////////////////////////////////
1341: // Utility
1342: ////////////////////////////////////////
1343: public String prettyPrintCategory(String catStr) {
1344: String retStr;
1345: if (catStr != null) {
1346: StringBuffer sb = new StringBuffer();
1347: // adding the category path elements
1348: StringTokenizer st = new StringTokenizer(catStr, ":");
1349: int nbTokens = st.countTokens();
1350: int tokenIndex = 0;
1351: while (st.hasMoreTokens()) {
1352: sb.append(st.nextToken());
1353: tokenIndex++;
1354: if (tokenIndex < nbTokens) {
1355: sb.append(" > ");
1356: }
1357: }
1358: retStr = sb.toString();
1359: } else {
1360: debugLogger.info("PSSH_CSPSA0070");
1361: retStr = "";
1362: }
1363: return retStr;
1364: }
1365: }
|