⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdbmuserlayoutstore.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      try {        String sQuery = "SELECT SS_ID FROM UP_SS_THEME WHERE STRUCT_SS_ID=" + structureStylesheetId;        log.debug("RDBMUserLayoutStore::getThemeStylesheetList() : " + sQuery);        ResultSet rs = stmt.executeQuery(sQuery);        try {          while (rs.next()) {            ThemeStylesheetDescription tsd = getThemeStylesheetDescription(rs.getInt("SS_ID"));            if (tsd != null)              list.put(new Integer(tsd.getId()), tsd);          }        } finally {          rs.close();        }      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }    return  list;  }  /**   * Obtain a list of theme stylesheet descriptions registered on the system   * @return a <code>Hashtable</code> mapping stylesheet id (<code>Integer</code> objects) to {@link ThemeStylesheetDescription} objects   * @exception Exception   */  public Hashtable getThemeStylesheetList() throws Exception {    Connection con = RDBMServices.getConnection();    Hashtable list = new Hashtable();    try {      Statement stmt = con.createStatement();      try {        String sQuery = "SELECT SS_ID FROM UP_SS_THEME";        log.debug("RDBMUserLayoutStore::getThemeStylesheetList() : " + sQuery);        ResultSet rs = stmt.executeQuery(sQuery);        try {          while (rs.next()) {            ThemeStylesheetDescription tsd = getThemeStylesheetDescription(rs.getInt("SS_ID"));            if (tsd != null)              list.put(new Integer(tsd.getId()), tsd);          }        } finally {          rs.close();        }      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }    return  list;  }  public ThemeStylesheetUserPreferences getThemeStylesheetUserPreferences (IPerson person, int profileId, int stylesheetId) throws Exception {    int userId = person.getID();    ThemeStylesheetUserPreferences tsup;    Connection con = RDBMServices.getConnection();    try {      Statement stmt = con.createStatement();      try {        // get stylesheet description        ThemeStylesheetDescription tsd = getThemeStylesheetDescription(stylesheetId);        // get user defined defaults                int layoutId = this.getLayoutID(userId, profileId);        ResultSet rs;        if (layoutId == 0) { // First time, grab the default layout for this user          String sQuery = "SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID=" + userId;          log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);          rs = stmt.executeQuery(sQuery);          try {            rs.next();            userId = rs.getInt(1);          } finally {            rs.close();          }        }                                String sQuery = "SELECT PARAM_NAME, PARAM_VAL FROM UP_SS_USER_PARM WHERE USER_ID=" + userId + " AND PROFILE_ID="            + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=2";        log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);        rs = stmt.executeQuery(sQuery);        try {          while (rs.next()) {            // stylesheet param            tsd.setStylesheetParameterDefaultValue(rs.getString(1), rs.getString(2));          }        } finally {          rs.close();        }        tsup = new ThemeStylesheetUserPreferences();        tsup.setStylesheetId(stylesheetId);        // fill stylesheet description with defaults        for (Enumeration e = tsd.getStylesheetParameterNames(); e.hasMoreElements();) {          String pName = (String)e.nextElement();          tsup.putParameterValue(pName, tsd.getStylesheetParameterDefaultValue(pName));        }        for (Enumeration e = tsd.getChannelAttributeNames(); e.hasMoreElements();) {          String pName = (String)e.nextElement();          tsup.addChannelAttribute(pName, tsd.getChannelAttributeDefaultValue(pName));        }        // get user preferences        sQuery = "SELECT PARAM_TYPE, PARAM_NAME, PARAM_VAL, ULS.STRUCT_ID, CHAN_ID FROM UP_SS_USER_ATTS UUSA, UP_LAYOUT_STRUCT ULS WHERE UUSA.USER_ID=" + userId + " AND PROFILE_ID="            + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=2 AND UUSA.STRUCT_ID = ULS.STRUCT_ID AND UUSA.USER_ID = ULS.USER_ID";        log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);        rs = stmt.executeQuery(sQuery);        try {          while (rs.next()) {            int param_type = rs.getInt(1);            if (rs.wasNull()) {              param_type = 0;            }            int structId = rs.getInt(4);            if (rs.wasNull()) {              structId = 0;            }            int chanId = rs.getInt(5);            if (rs.wasNull()) {              chanId = 0;            }            if (param_type == 1) {              // stylesheet param              log.error( "RDBMUserLayoutStore::getThemeStylesheetUserPreferences() :  stylesheet global params should be specified in the user defaults table ! UP_SS_USER_ATTS is corrupt. (userId="                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)                  + ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));            }            else if (param_type == 2) {              // folder attribute              log.error( "RDBMUserLayoutStore::getThemeStylesheetUserPreferences() :  folder attribute specified for the theme stylesheet! UP_SS_USER_ATTS corrupt. (userId="                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)                  + ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));            }            else if (param_type == 3) {              // channel attribute              tsup.setChannelAttributeValue(getStructId(structId,chanId), rs.getString(2), rs.getString(3));            }            else {              // unknown param type              log.error( "RDBMUserLayoutStore::getThemeStylesheetUserPreferences() : unknown param type encountered! DB corrupt. (userId="                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)                  + ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));            }          }        } finally {          rs.close();        }      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }    return  tsup;  }  // private helper modules that retreive information from the DOM structure of the description files  private String getName (Document descr) {    NodeList names = descr.getElementsByTagName("name");    Node name = null;    for (int i = names.getLength() - 1; i >= 0; i--) {      name = names.item(i);      if (name.getParentNode().getNodeName().equals("stylesheetdescription"))        break;      else        name = null;    }    if (name != null) {      return  this.getTextChildNodeValue(name);    }    else {      log.debug("RDBMUserLayoutStore::getName() : no \"name\" element was found under the \"stylesheetdescription\" node!");      return  null;    }  }  private String getRootElementTextValue (Document descr, String elementName) {    NodeList names = descr.getElementsByTagName(elementName);    Node name = null;    for (int i = names.getLength() - 1; i >= 0; i--) {      name = names.item(i);      if (name.getParentNode().getNodeName().equals("stylesheetdescription"))        break;      else        name = null;    }    if (name != null) {      return  this.getTextChildNodeValue(name);    }    else {      log.debug("RDBMUserLayoutStore::getRootElementTextValue() : no \"" + elementName + "\" element was found under the \"stylesheetdescription\" node!");      return  null;    }  }  private String getDescription (Document descr) {    NodeList descriptions = descr.getElementsByTagName("description");    Node description = null;    for (int i = descriptions.getLength() - 1; i >= 0; i--) {      description = descriptions.item(i);      if (description.getParentNode().getNodeName().equals("stylesheetdescription"))        break;      else        description = null;    }    if (description != null) {      return  this.getTextChildNodeValue(description);    }    else {      log.debug("RDBMUserLayoutStore::getDescription() : no \"description\" element was found under the \"stylesheetdescription\" node!");      return  null;    }  }  private void populateParameterTable (Document descr, CoreStylesheetDescription csd) {    NodeList parametersNodes = descr.getElementsByTagName("parameters");    Node parametersNode = null;    for (int i = parametersNodes.getLength() - 1; i >= 0; i--) {      parametersNode = parametersNodes.item(i);      if (parametersNode.getParentNode().getNodeName().equals("stylesheetdescription"))        break;      else        parametersNode = null;    }    if (parametersNode != null) {      NodeList children = parametersNode.getChildNodes();      for (int i = children.getLength() - 1; i >= 0; i--) {        Node child = children.item(i);        if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("parameter")) {          Element parameter = (Element)children.item(i);          // process a <parameter> node          String name = parameter.getAttribute("name");          String description = null;          String defaultvalue = null;          NodeList pchildren = parameter.getChildNodes();          for (int j = pchildren.getLength() - 1; j >= 0; j--) {            Node pchild = pchildren.item(j);            if (pchild.getNodeType() == Node.ELEMENT_NODE) {              if (pchild.getNodeName().equals("defaultvalue")) {                defaultvalue = this.getTextChildNodeValue(pchild);              }              else if (pchild.getNodeName().equals("description")) {                description = this.getTextChildNodeValue(pchild);              }            }          }          log.debug("RDBMUserLayoutStore::populateParameterTable() : adding a stylesheet parameter : (\""              + name + "\",\"" + defaultvalue + "\",\"" + description + "\")");          csd.addStylesheetParameter(name, defaultvalue, description);        }      }    }  }  private void populateFolderAttributeTable (Document descr, StructureStylesheetDescription cxsd) {    NodeList parametersNodes = descr.getElementsByTagName("parameters");    NodeList folderattributesNodes = descr.getElementsByTagName("folderattributes");    Node folderattributesNode = null;    for (int i = folderattributesNodes.getLength() - 1; i >= 0; i--) {      folderattributesNode = folderattributesNodes.item(i);      if (folderattributesNode.getParentNode().getNodeName().equals("stylesheetdescription"))        break;      else        folderattributesNode = null;    }    if (folderattributesNode != null) {      NodeList children = folderattributesNode.getChildNodes();      for (int i = children.getLength() - 1; i >= 0; i--) {        Node child = children.item(i);        if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("attribute")) {          Element attribute = (Element)children.item(i);          // process a <attribute> node          String name = attribute.getAttribute("name");          String description = null;          String defaultvalue = null;          NodeList pchildren = attribute.getChildNodes();          for (int j = pchildren.getLength() - 1; j >= 0; j--) {            Node pchild = pchildren.item(j);            if (pchild.getNodeType() == Node.ELEMENT_NODE) {              if (pchild.getNodeName().equals("defaultvalue")) {                defaultvalue = this.getTextChildNodeValue(pchild);              }              else if (pchild.getNodeName().equals("description")) {                description = this.getTextChildNodeValue(pchild);              }            }          }          log.debug("RDBMUserLayoutStore::populateFolderAttributeTable() : adding a stylesheet folder attribute : (\""              + name + "\",\"" + defaultvalue + "\",\"" + description + "\")");          cxsd.addFolderAttribute(name, defaultvalue, description);        }      }    }  }  private void populateChannelAttributeTable (Document descr, CoreXSLTStylesheetDescription cxsd) {    NodeList channelattributesNodes = descr.getElementsByTagName("channelattributes");    Node channelattributesNode = null;    for (int i = channelattributesNodes.getLength() - 1; i >= 0; i--) {      channelattributesNode = channelattributesNodes.item(i);      if (channelattributesNode.getParentNode().getNodeName().equals("stylesheetdescription"))        break;      else        channelattributesNode = null;    }    if (channelattributesNode != null) {      NodeList children = channelattributesNode.get

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -