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

📄 rdbmuserlayoutstore.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
  }  /**   * convert true/false into Y/N for database   * @param value to check   * @result boolean   */  protected static final boolean xmlBool (String value) {      return (value != null && value.equals("true") ? true : false);  }  public void deleteUserProfile(IPerson person, int profileId) throws Exception {    int userId = person.getID();    deleteUserProfile(userId,profileId);  }  private Document getDOM(String uri) throws Exception {    DOMResult result = new DOMResult();    SAXSource source = new SAXSource(new InputSource(      ResourceLoader.getResourceAsStream(this.getClass(), uri)));    TransformerFactory tFactory = TransformerFactory.newInstance();    Transformer emptytr = tFactory.newTransformer();    emptytr.transform(source, result);    // need to return a Document    Node node = result.getNode();    if (node instanceof Document) {      return (Document)node;    }    Document dom = DocumentFactory.getNewDocument();    dom.appendChild(dom.importNode(node, true));    return dom;  }  private void deleteUserProfile(int userId, int profileId) throws Exception {    Connection con = RDBMServices.getConnection();    try {      Statement stmt = con.createStatement();      try {        String sQuery = "DELETE FROM UP_USER_PROFILE WHERE USER_ID=" + userId + " AND PROFILE_ID=" + Integer.toString(profileId);        log.debug("RDBMUserLayoutStore::deleteUserProfile() : " + sQuery);        stmt.executeUpdate(sQuery);        // remove profile mappings        sQuery= "DELETE FROM UP_USER_UA_MAP WHERE USER_ID=" + userId + " AND PROFILE_ID=" + Integer.toString(profileId);        log.debug("RDBMUserLayoutStore::deleteUserProfile() : " + sQuery);        stmt.executeUpdate(sQuery);        // remove parameter information        sQuery= "DELETE FROM UP_SS_USER_PARM WHERE USER_ID=" + userId + " AND PROFILE_ID=" + Integer.toString(profileId);        log.debug("RDBMUserLayoutStore::deleteUserProfile() : " + sQuery);        stmt.executeUpdate(sQuery);        sQuery= "DELETE FROM UP_SS_USER_ATTS WHERE USER_ID=" + userId + " AND PROFILE_ID=" + Integer.toString(profileId);        log.debug("RDBMUserLayoutStore::deleteUserProfile() : " + sQuery);        stmt.executeUpdate(sQuery);      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }  }  /**   * Dump a document tree structure on stdout   * @param node   * @param indent   */  public static final void dumpDoc (Node node, String indent) {    if (node == null) {      return;    }    if (node instanceof Element) {      System.err.print(indent + "element: tag=" + ((Element)node).getTagName() + " ");    }    else if (node instanceof Document) {      System.err.print("document:");    }    else {      System.err.print(indent + "node:");    }    System.err.println("name=" + node.getNodeName() + " value=" + node.getNodeValue());    NamedNodeMap nm = node.getAttributes();    if (nm != null) {      for (int i = 0; i < nm.getLength(); i++) {        System.err.println(indent + " " + nm.item(i).getNodeName() + ": '" + nm.item(i).getNodeValue() + "'");      }      System.err.println(indent + "--");    }    if (node.hasChildNodes()) {      dumpDoc(node.getFirstChild(), indent + "   ");    }    dumpDoc(node.getNextSibling(), indent);  }  /**   *   * CoreStyleSheet   *   */  public Hashtable getMimeTypeList () throws Exception {    Connection con = RDBMServices.getConnection();    try {      Statement stmt = con.createStatement();      try {        String sQuery = "SELECT A.MIME_TYPE, A.MIME_TYPE_DESCRIPTION FROM UP_MIME_TYPE A, UP_SS_MAP B WHERE B.MIME_TYPE=A.MIME_TYPE";        log.debug("RDBMUserLayoutStore::getMimeTypeList() : " + sQuery);        ResultSet rs = stmt.executeQuery(sQuery);        try {          Hashtable list = new Hashtable();          while (rs.next()) {            list.put(rs.getString("MIME_TYPE"), rs.getString("MIME_TYPE_DESCRIPTION"));          }          return list;        } finally {          rs.close();        }      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }  }  /**   * Return the next available channel structure id for a user   * @param person   * @return the next available channel structure id   */  public String generateNewChannelSubscribeId (IPerson person) throws Exception {    return  getNextStructId(person, channelPrefix);  }  /**   * Return the next available folder structure id for a user   * @param person   * @return a <code>String</code> that is the next free structure ID   * @exception Exception   */  public String generateNewFolderId (IPerson person) throws Exception {    return  getNextStructId(person, folderPrefix);  }  /**   * Return the next available structure id for a user   * @param person   * @param prefix   * @return next free structure ID   * @exception Exception   */  protected synchronized String getNextStructId (IPerson person, String prefix) throws Exception {    int userId = person.getID();    Connection con = RDBMServices.getConnection();    try {      RDBMServices.setAutoCommit(con, false);      Statement stmt = con.createStatement();      try {        String sQuery = "SELECT NEXT_STRUCT_ID FROM UP_USER WHERE USER_ID=" + userId;        for (int i = 0; i < 25; i++) {          log.debug("RDBMUserLayoutStore::getNextStructId(): " + sQuery);          ResultSet rs = stmt.executeQuery(sQuery);          int currentStructId;          try {            rs.next();            currentStructId = rs.getInt(1);          } finally {            rs.close();          }          int nextStructId = currentStructId + 1;          try {            String sUpdate = "UPDATE UP_USER SET NEXT_STRUCT_ID=" + nextStructId + " WHERE USER_ID=" + userId + " AND NEXT_STRUCT_ID="                + currentStructId;            log.debug("RDBMUserLayoutStore::getNextStructId(): " + sUpdate);            stmt.executeUpdate(sUpdate);            RDBMServices.commit(con);            return  prefix + nextStructId;          } catch (SQLException sqle) {            RDBMServices.rollback(con);            // Assume a concurrent update. Try again after some random amount of milliseconds.            Thread.sleep(java.lang.Math.round(java.lang.Math.random()* 3 * 1000)); // Retry in up to 3 seconds          }        }      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }    throw new SQLException("Unable to generate a new structure id for user " + userId);  }  /**   * Return the Structure ID tag   * @param  structId   * @param  chanId   * @return ID tag   */  protected String getStructId(int structId, int chanId) {    if (chanId == 0) {      return folderPrefix + structId;    } else {      return channelPrefix + structId;    }  }  /**   * Obtain structure stylesheet description object for a given structure stylesheet id.   * @param stylesheetId the id of the structure stylesheet   * @return structure stylesheet description   */  public StructureStylesheetDescription getStructureStylesheetDescription (int stylesheetId) throws Exception {    StructureStylesheetDescription ssd = null;    Connection con = null;    try {      con = RDBMServices.getConnection();      Statement stmt = con.createStatement();      int dbOffset = 0;      String sQuery = "SELECT SS_NAME,SS_URI,SS_DESCRIPTION_URI,SS_DESCRIPTION_TEXT";      if (RDBMServices.supportsOuterJoins) {        sQuery += ",TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM " + RDBMServices.joinQuery.getQuery("ss_struct");        dbOffset = 4;      } else {        sQuery += " FROM UP_SS_STRUCT USS WHERE";      }      sQuery += " USS.SS_ID=" + stylesheetId;      log.debug("RDBMUserLayoutStore::getStructureStylesheetDescription(): " + sQuery);      ResultSet rs = stmt.executeQuery(sQuery);      try {        if (rs.next()) {          ssd = new StructureStylesheetDescription();          ssd.setId(stylesheetId);          ssd.setStylesheetName(rs.getString(1));          ssd.setStylesheetURI(rs.getString(2));          ssd.setStylesheetDescriptionURI(rs.getString(3));          ssd.setStylesheetWordDescription(rs.getString(4));        }        if (!RDBMServices.supportsOuterJoins) {          rs.close();          // retrieve stylesheet params and attributes          sQuery = "SELECT TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM UP_SS_STRUCT_PAR WHERE SS_ID=" + stylesheetId;          log.debug("RDBMUserLayoutStore::getStructureStylesheetDescription(): " + sQuery);          rs = stmt.executeQuery(sQuery);        }        while (true) {          if (!RDBMServices.supportsOuterJoins && !rs.next()) {            break;          }          int type = rs.getInt(dbOffset + 1);          if (rs.wasNull()){            break;          }          if (type == 1) {            // param            ssd.addStylesheetParameter(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));          }          else if (type == 2) {            // folder attribute            ssd.addFolderAttribute(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));          }          else if (type == 3) {            // channel attribute            ssd.addChannelAttribute(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));          }          else {            log.debug("RDBMUserLayoutStore::getStructureStylesheetDescription() : encountered param of unknown type! (stylesheetId="                + stylesheetId + " param_name=\"" + rs.getString(dbOffset + 2) + "\" type=" + type + ").");          }          if (RDBMServices.supportsOuterJoins && !rs.next()) {            break;          }        }      } finally {        try { rs.close(); } catch (Exception e) {}        try { stmt.close(); } catch (Exception e) {}      }    } finally {      RDBMServices.releaseConnection(con);    }    return  ssd;  }  /**   * Obtain ID for known structure stylesheet name   * @param ssName name of the structure stylesheet   * @return id or null if no stylesheet matches the name given.   */  public Integer getStructureStylesheetId (String ssName) throws Exception {    Connection con = null;     Statement stmt = null;     ResultSet rs = null;     try {      con = RDBMServices.getConnection();      RDBMServices.setAutoCommit(con, false);      stmt = con.createStatement();      String sQuery = "SELECT SS_ID FROM UP_SS_STRUCT WHERE SS_NAME='" + ssName + "'";      rs = stmt.executeQuery(sQuery);      if (rs.next()) {        int id = rs.getInt("SS_ID");        if (rs.wasNull()) {          id = 0;

⌨️ 快捷键说明

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