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

📄 rdbmuserlayoutstore.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        // Roll back the transaction        RDBMServices.rollback(con);        throw  e;      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }  }  /**   * Registers a NEW theme stylesheet with the database.   * @param tsd Stylesheet description object   * @return an <code>Integer</code> id of the registered Theme Stylesheet if successful;   *                 <code>null</code> otherwise.   */  public Integer addThemeStylesheetDescription (ThemeStylesheetDescription tsd) throws Exception {    Connection con = RDBMServices.getConnection();    try {      // Set autocommit false for the connection      RDBMServices.setAutoCommit(con, false);      Statement stmt = con.createStatement();      try {        // we assume that this is a new stylesheet.        int id = csdb.getIncrementIntegerId("UP_SS_THEME");        tsd.setId(id);        String sQuery = "INSERT INTO UP_SS_THEME (SS_ID,SS_NAME,SS_URI,SS_DESCRIPTION_URI,SS_DESCRIPTION_TEXT,STRUCT_SS_ID,SAMPLE_URI,SAMPLE_ICON_URI,MIME_TYPE,DEVICE_TYPE,SERIALIZER_NAME,UP_MODULE_CLASS) VALUES ("            + id + ",'" + tsd.getStylesheetName() + "','" + tsd.getStylesheetURI() + "','" + tsd.getStylesheetDescriptionURI()            + "','" + tsd.getStylesheetWordDescription() + "'," + tsd.getStructureStylesheetId() + ",'" + tsd.getSamplePictureURI()            + "','" + tsd.getSampleIconURI() + "','" + tsd.getMimeType() + "','" + tsd.getDeviceType() + "','" + tsd.getSerializerName()            + "','" + tsd.getCustomUserPreferencesManagerClass() + "')";        log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription(): " + sQuery);        stmt.executeUpdate(sQuery);        // insert all stylesheet params        for (Enumeration e = tsd.getStylesheetParameterNames(); e.hasMoreElements();) {          String pName = (String)e.nextElement();          sQuery = "INSERT INTO UP_SS_THEME_PARM (SS_ID,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT,TYPE) VALUES (" + id +              ",'" + pName + "','" + tsd.getStylesheetParameterDefaultValue(pName) + "','" + tsd.getStylesheetParameterWordDescription(pName)              + "',1)";          log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription(): " + sQuery);          stmt.executeUpdate(sQuery);        }        // insert all channel attributes        for (Enumeration e = tsd.getChannelAttributeNames(); e.hasMoreElements();) {          String pName = (String)e.nextElement();          sQuery = "INSERT INTO UP_SS_THEME_PARM (SS_ID,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT,TYPE) VALUES (" + id +              ",'" + pName + "','" + tsd.getChannelAttributeDefaultValue(pName) + "','" + tsd.getChannelAttributeWordDescription(pName)              + "',3)";          log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription(): " + sQuery);          stmt.executeUpdate(sQuery);        }        // Commit the transaction        RDBMServices.commit(con);        return  new Integer(id);      } catch (Exception e) {        // Roll back the transaction        RDBMServices.rollback(con);        throw  e;      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }  }  /**   * Update the theme stylesheet description.   * @param stylesheetDescriptionURI   * @param stylesheetURI   * @param stylesheetId   * @return true if update succeeded, otherwise false   */  public boolean updateThemeStylesheetDescription (String stylesheetDescriptionURI, String stylesheetURI, int stylesheetId) {    try {      Document stylesheetDescriptionXML = getDOM(stylesheetDescriptionURI);      String ssName = this.getRootElementTextValue(stylesheetDescriptionXML, "parentStructureStylesheet");      // should thrown an exception      if (ssName == null)        return  false;      // determine id of the parent structure stylesheet      Integer ssId = getStructureStylesheetId(ssName);      // stylesheet not found, should thrown an exception here      if (ssId == null)        return  false;      ThemeStylesheetDescription sssd = new ThemeStylesheetDescription();      sssd.setId(stylesheetId);      sssd.setStructureStylesheetId(ssId.intValue());      String xmlStylesheetName = this.getName(stylesheetDescriptionXML);      String xmlStylesheetDescriptionText = this.getDescription(stylesheetDescriptionXML);      sssd.setStylesheetName(xmlStylesheetName);      sssd.setStylesheetURI(stylesheetURI);      sssd.setStylesheetDescriptionURI(stylesheetDescriptionURI);      sssd.setStylesheetWordDescription(xmlStylesheetDescriptionText);      sssd.setMimeType(this.getRootElementTextValue(stylesheetDescriptionXML, "mimeType"));      log.debug("RDBMUserLayoutStore::updateThemeStylesheetDescription() : setting mimetype=\""          + sssd.getMimeType() + "\"");      sssd.setSerializerName(this.getRootElementTextValue(stylesheetDescriptionXML, "serializer"));      log.debug("RDBMUserLayoutStore::updateThemeStylesheetDescription() : setting serializerName=\""          + sssd.getSerializerName() + "\"");      sssd.setCustomUserPreferencesManagerClass(this.getRootElementTextValue(stylesheetDescriptionXML, "userPreferencesModuleClass"));      sssd.setSamplePictureURI(this.getRootElementTextValue(stylesheetDescriptionXML, "samplePictureURI"));      sssd.setSampleIconURI(this.getRootElementTextValue(stylesheetDescriptionXML, "sampleIconURI"));      sssd.setDeviceType(this.getRootElementTextValue(stylesheetDescriptionXML, "deviceType"));      // populate parameter and attriute tables      this.populateParameterTable(stylesheetDescriptionXML, sssd);      this.populateChannelAttributeTable(stylesheetDescriptionXML, sssd);      updateThemeStylesheetDescription(sssd);    } catch (Exception e) {      log.debug("Exception updating theme stylesheet description=" +            "[" + stylesheetDescriptionURI + "] stylesheetUri=["+ stylesheetURI +             "] stylesheetId=["+ stylesheetId + "]", e);      return  false;    }    return  true;  }  /**   * Update the structure stylesheet description   * @param stylesheetDescriptionURI   * @param stylesheetURI   * @param stylesheetId   * @return true if update succeeded, otherwise false   */  public boolean updateStructureStylesheetDescription (String stylesheetDescriptionURI, String stylesheetURI, int stylesheetId) {    try {      Document stylesheetDescriptionXML = getDOM(stylesheetDescriptionURI);      StructureStylesheetDescription fssd = new StructureStylesheetDescription();      String xmlStylesheetName = this.getName(stylesheetDescriptionXML);      String xmlStylesheetDescriptionText = this.getDescription(stylesheetDescriptionXML);      fssd.setId(stylesheetId);      fssd.setStylesheetName(xmlStylesheetName);      fssd.setStylesheetURI(stylesheetURI);      fssd.setStylesheetDescriptionURI(stylesheetDescriptionURI);      fssd.setStylesheetWordDescription(xmlStylesheetDescriptionText);      // populate parameter and attriute tables      this.populateParameterTable(stylesheetDescriptionXML, fssd);      this.populateFolderAttributeTable(stylesheetDescriptionXML, fssd);      this.populateChannelAttributeTable(stylesheetDescriptionXML, fssd);      // now write out the database record      updateStructureStylesheetDescription(fssd);    } catch (Exception e) {      log.debug("Exception updating structure stylesheet description " +            "stylesheetDescriptionUri=[" + stylesheetDescriptionURI + "]" +                    " stylesheetUri=[" + stylesheetURI +                     "] stylesheetId=" + stylesheetId , e);      return  false;    }    return  true;  }  /**   * Add a structure stylesheet description   * @param stylesheetDescriptionURI   * @param stylesheetURI   * @return an <code>Integer</code> id of the registered Structure Stylesheet description object if successful;   *                      <code>null</code> otherwise.   */  public Integer addStructureStylesheetDescription (String stylesheetDescriptionURI, String stylesheetURI) {    // need to read in the description file to obtain information such as name, word description and media list    try {      Document stylesheetDescriptionXML = getDOM(stylesheetDescriptionURI);      StructureStylesheetDescription fssd = new StructureStylesheetDescription();      String xmlStylesheetName = this.getName(stylesheetDescriptionXML);      String xmlStylesheetDescriptionText = this.getDescription(stylesheetDescriptionXML);      fssd.setStylesheetName(xmlStylesheetName);      fssd.setStylesheetURI(stylesheetURI);      fssd.setStylesheetDescriptionURI(stylesheetDescriptionURI);      fssd.setStylesheetWordDescription(xmlStylesheetDescriptionText);      // populate parameter and attriute tables      this.populateParameterTable(stylesheetDescriptionXML, fssd);      this.populateFolderAttributeTable(stylesheetDescriptionXML, fssd);      this.populateChannelAttributeTable(stylesheetDescriptionXML, fssd);      // now write out the database record      // first the basic record      //UserLayoutStoreFactory.getUserLayoutStoreImpl().addStructureStylesheetDescription(xmlStylesheetName, stylesheetURI, stylesheetDescriptionURI, xmlStylesheetDescriptionText);      return  addStructureStylesheetDescription(fssd);    } catch (Exception e) {      log.debug("Error adding stylesheet: " +            "description Uri=[" + stylesheetDescriptionURI + "] " +                    "stylesheetUri=[" + stylesheetURI + "]", e);    }    return  null;  }  /**   * Add theme stylesheet description   * @param stylesheetDescriptionURI   * @param stylesheetURI   * @return an <code>Integer</code> id of the registered Theme Stylesheet if successful;   *                 <code>null</code> otherwise.   */  public Integer addThemeStylesheetDescription (String stylesheetDescriptionURI, String stylesheetURI) {    // need to read iN the description file to obtain information such as name, word description and mime type list    try {      Document stylesheetDescriptionXML = getDOM(stylesheetDescriptionURI);      log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription() : stylesheet name = " + this.getName(stylesheetDescriptionXML));      log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription() : stylesheet description = " + this.getDescription(stylesheetDescriptionXML));      String ssName = this.getRootElementTextValue(stylesheetDescriptionXML, "parentStructureStylesheet");      // should thrown an exception      if (ssName == null)        return  null;      // determine id of the parent structure stylesheet      Integer ssId = getStructureStylesheetId(ssName);      // stylesheet not found, should thrown an exception here      if (ssId == null)        return  null;      ThemeStylesheetDescription sssd = new ThemeStylesheetDescription();      sssd.setStructureStylesheetId(ssId.intValue());      String xmlStylesheetName = this.getName(stylesheetDescriptionXML);      String xmlStylesheetDescriptionText = this.getDescription(stylesheetDescriptionXML);      sssd.setStylesheetName(xmlStylesheetName);      sssd.setStylesheetURI(stylesheetURI);      sssd.setStylesheetDescriptionURI(stylesheetDescriptionURI);      sssd.setStylesheetWordDescription(xmlStylesheetDescriptionText);      sssd.setMimeType(this.getRootElementTextValue(stylesheetDescriptionXML, "mimeType"));      log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription() : setting mimetype=\""          + sssd.getMimeType() + "\"");      sssd.setSerializerName(this.getRootElementTextValue(stylesheetDescriptionXML, "serializer"));      log.debug("RDBMUserLayoutStore::addThemeStylesheetDescription() : setting serializerName=\""          + sssd.getSerializerName() + "\"");      sssd.setCustomUserPreferencesManagerClass(this.getRootElementTextValue(stylesheetDescriptionXML, "userPreferencesModuleClass"));      sssd.setSamplePictureURI(this.getRootElementTextValue(stylesheetDescriptionXML, "samplePictureURI"));      sssd.setSampleIconURI(this.getRootElementTextValue(stylesheetDescriptionXML, "sampleIconURI"));      sssd.setDeviceType(this.getRootElementTextValue(stylesheetDescriptionXML, "deviceType"));      // populate parameter and attriute tables      this.populateParameterTable(stylesheetDescriptionXML, sssd);      this.populateChannelAttributeTable(stylesheetDescriptionXML, sssd);      return  addThemeStylesheetDescription(sssd);    } catch (Exception e) {      log.debug("Exception adding theme stylesheet description " +               "description uri=[" + stylesheetDescriptionURI + "] " +              "stylesheet uri=[" + stylesheetURI + "]", e);    }    return  null;  }  /**   * Add a user profile   * @param person   * @param profile   * @return userProfile   * @exception Exception   */  public UserProfile addUserProfile (IPerson person, UserProfile profile) throws Exception {    int userId = person.getID();    // generate an id for this profile    Connection con = RDBMServices.getConnection();    try {      int id = csdb.getIncrementIntegerId("UP_USER_PROFILE");      profile.setProfileId(id);      Statement stmt = con.createStatement();      try {        String sQuery = "INSERT INTO UP_USER_PROFILE (USER_ID,PROFILE_ID,PROFILE_NAME,STRUCTURE_SS_ID,THEME_SS_ID,DESCRIPTION, LAYOUT_ID) VALUES ("            + userId + "," + profile.getProfileId() + ",'" + profile.getProfileName() + "'," + profile.getStructureStylesheetId()            + "," + profile.getThemeStylesheetId() + ",'" + profile.getProfileDescription() + "', "+profile.getLayoutId()+")";        log.debug("RDBMUserLayoutStore::addUserProfile(): " + sQuery);        stmt.executeUpdate(sQuery);      } finally {        stmt.close();      }    } finally {      RDBMServices.releaseConnection(con);    }    return  profile;  }  /**   * Checks if a channel has been approved   * @param approvedDate   * @return boolean Channel is approved   */   protected static boolean channelApproved(java.util.Date approvedDate) {      java.util.Date rightNow = new java.util.Date();      return (approvedDate != null && rightNow.after(approvedDate));   }  /**   * Create a layout   * @param layoutStructure   * @param doc   * @param root   * @param structId   * @exception java.sql.SQLException   */   protected final void createLayout (HashMap layoutStructure, Document doc,        Element root, int structId) throws java.sql.SQLException, Exception {      while (structId != 0) {        if (DEBUG>1) {          System.err.println("CreateLayout(" + structId + ")");        }        LayoutStructure ls = (LayoutStructure) layoutStructure.get(new Integer(structId));        Element structure = ls.getStructureDocument(doc);        root.appendChild(structure);        if (!ls.isChannel()) {          // Folder          createLayout(layoutStructure, doc,  structure, ls.getChildId());        }        structId = ls.getNextId();      }

⌨️ 快捷键说明

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