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

📄 memberxml.java

📁 解觖java技术中后台无法上传数给的情况
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            permission1=XMLUtil.stringToIntDef(permission, MVNForumPermission.PERMISSION_NO_PERMISSIONS);
        } catch (NumberFormatException e) {
            throw new CreateException("Invalid data for a member permission. Expected a number.");
        }
        try {
            DAOFactory.getMemberPermissionDAO().create(DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName), permission1);
        } catch (DuplicateKeyException e) {
            //ignore if already had that permission
        }
    }

    /**
     * Creates a message folder for this member. In order to know which member we are
     * reffering to, this method is supposed to be called after {@link #setMemberID(String)},
     * {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
     * or {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
     * have been called. Otherwise, this message folder will be simply ignored.
     *
     * @param folderName Name of a folder to be created.
     * @param folderOrder Can be null.
     * @param folderCreationDate Can be null.
     * @param folderModifiedDate Can be null.
     *
     * @throws CreateException
     * @throws DatabaseException
     * @throws DuplicateKeyException
     * @throws ForeignKeyNotFoundException
     */
    public void addMessageFolder(String folderName, String folderOrder,
                String folderCreationDate, String folderModifiedDate)
    throws CreateException, DatabaseException, DuplicateKeyException, ForeignKeyNotFoundException {
        if (memberID<0) {
            throw new CreateException("Found message folder that is not assigned to any known member.");
        }
        if ( (folderName==null) || (folderName.equals("")) ) {
            throw new CreateException("Can't create a message folder with empty FolderName.");
        }

        int folderOrder1;
        java.sql.Timestamp folderCreationDate1;
        java.sql.Timestamp folderModifiedDate1;
        try {
            folderOrder1= XMLUtil.stringToIntDef(folderOrder, 0);
            folderCreationDate1= XMLUtil.stringToSqlTimestampDefNow(folderCreationDate);
            folderModifiedDate1= XMLUtil.stringToSqlTimestampDefNow(folderModifiedDate);
        } catch (NumberFormatException e) {
            throw new CreateException("Invalid data for a message folder. Expected a number.");
        }

        folderName=EnableHtmlTagFilter.filter(folderName);
        int folderStatus = 0;
        int folderOption = 0;
        int folderType = 0;
        DAOFactory.getMessageFolderDAO().create(folderName, memberID, folderOrder1,
                                                folderStatus, folderOption, folderType,
                                                folderCreationDate1, folderModifiedDate1);
    }

    /**
     * Adds a global watch for this member. In order to know which member we are
     * reffering to, this method is supposed to be called after {@link #setMemberID(String)},
     * {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
     * or {@link #addMember(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)}
     * have been called. Otherwise, this watch will be simply ignored.
     *
     * @param watchType Can be null.
     * @param watchOption Can be null.
     * @param watchStatus Can be null.
     * @param watchCreationDate Can be null.
     * @param watchLastSentDate Can be null.
     * @param watchEndDate Can be null.
     *
     * @throws BadInputException
     * @throws CreateException
     * @throws DatabaseException
     * @throws DuplicateKeyException
     * @throws ForeignKeyNotFoundException
     */
    public void addGlobalWatch(String watchType, String watchOption,
                String watchStatus, String watchCreationDate,
                String watchLastSentDate, String watchEndDate)
        throws CreateException, DatabaseException, DuplicateKeyException, ForeignKeyNotFoundException {
        if (memberID<0) {
            throw new CreateException("Found global watch that is not assigned to any known member.");
        }

        int watchType1;
        int watchOption1;
        int watchStatus1;
        java.sql.Timestamp watchCreationDate1;
        java.sql.Timestamp watchLastSentDate1;
        java.sql.Timestamp watchEndDate1;

        try {
            watchType1= XMLUtil.stringToIntDef(watchType, 0);
            watchOption1= XMLUtil.stringToIntDef(watchOption, 0);
            watchStatus1= XMLUtil.stringToIntDef(watchStatus, 0);
            watchCreationDate1= XMLUtil.stringToSqlTimestampDefNow(watchCreationDate);
            watchLastSentDate1= XMLUtil.stringToSqlTimestampDefNull(watchLastSentDate);
            watchEndDate1= XMLUtil.stringToSqlTimestampDefNull(watchEndDate);
        } catch (NumberFormatException e) {
            throw new CreateException("Invalid data for a global watch. Expected a number.");
        }

        DAOFactory.getWatchDAO().create(
             memberID, 0/*categoryID*/, 0/*forumID*/, 0/*threadID*/,
             watchType1, watchOption1, watchStatus1,
             watchCreationDate1, watchLastSentDate1, watchEndDate1);
    }


// ===============================================================
// ==================== STATIC EXPORT METHODS ====================
// ===============================================================

    public static void exportMessageFoldersForMember(XMLWriter xmlWriter, String memberName)
    throws ForeignKeyNotFoundException, IOException, DatabaseException, ExportException {
        try {
            exportMessageFoldersForMember(xmlWriter,
                  DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName));
        } catch (ObjectNotFoundException e) {
            throw new ForeignKeyNotFoundException("Can't find member with name \""+memberName+"\".");
        }
    }

    public static void exportMessageFoldersForMember(XMLWriter xmlWriter, int memberID)
    throws IOException, DatabaseException, ExportException {
        Collection messageFolders=ExportWebHelper.execSqlQuery(
                   "SELECT FolderName, FolderOrder, FolderCreationDate, FolderModifiedDate"+
                   " FROM "+MessageFolderDAO.TABLE_NAME+
                   " WHERE MemberID="+Integer.toString(memberID));
        Iterator iter=messageFolders.iterator();
        String[] messageFolder=null;
        //try {
            xmlWriter.startElement("MessageFolderList");
            try {
                while ( (messageFolder=(String[])iter.next()) !=null) {
                    if (messageFolder.length!=4) {
                        throw new ExportException("Error while retrieving data about message folder for memberID=="+memberID);
                    }
                    xmlWriter.startElement("MessageFolder");
                    xmlWriter.startElement("FolderName");
                    xmlWriter.writeData(DisableHtmlTagFilter.filter(messageFolder[0]));
                    xmlWriter.endElement("FolderName");
                    xmlWriter.startElement("FolderOrder");
                    xmlWriter.writeData(messageFolder[1]);
                    xmlWriter.endElement("FolderOrder");
                    xmlWriter.startElement("FolderCreationDate");
                    xmlWriter.writeData(messageFolder[2]);
                    xmlWriter.endElement("FolderCreationDate");
                    xmlWriter.startElement("FolderModifiedDate");
                    xmlWriter.writeData(messageFolder[3]);
                    xmlWriter.endElement("FolderModifiedDate");
                    xmlWriter.endElement("MessageFolder");
                }
            } catch (NoSuchElementException e) {
                //no more database records
            }
            xmlWriter.endElement("MessageFolderList");
         //} catch throw exportexception
    }

    public static void exportGlobalPermissionsForMember(XMLWriter xmlWriter, String memberName)
    throws ForeignKeyNotFoundException, IOException, DatabaseException, ExportException {
        try {
            exportGlobalPermissionsForMember(xmlWriter,
                  DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName));
        } catch (ObjectNotFoundException e) {
            throw new ForeignKeyNotFoundException("Can't find member with name \""+memberName+"\".");
        }
    }

    public static void exportGlobalPermissionsForMember(XMLWriter xmlWriter, int memberID)
    throws IOException, DatabaseException, ExportException {
        Collection globalPermissions=ExportWebHelper.execSqlQuery(
                   "SELECT Permission"+
                   " FROM "+MemberPermissionDAO.TABLE_NAME+
                   " WHERE MemberID="+Integer.toString(memberID));
        Iterator iter=globalPermissions.iterator();
        String[] globalPermission=null;
        //try {
            xmlWriter.startElement("GlobalPermissionList");
            try {
                while ( (globalPermission=(String[])iter.next()) !=null) {
                    if (globalPermission.length!=1) {
                        throw new ExportException("Error while retrieving data about global permissions for memberID=="+memberID);
                    }
                    xmlWriter.startElement("GlobalPermission");
                    xmlWriter.writeData(globalPermission[0]);
                    xmlWriter.endElement("GlobalPermission");
                }
            } catch (NoSuchElementException e) {
                //no more database records
            }
            xmlWriter.endElement("GlobalPermissionList");
         //} catch throw exportexception
    }

    public static void exportGlobalWatchesForMember(XMLWriter xmlWriter, String memberName)
    throws ForeignKeyNotFoundException, IOException, DatabaseException, ExportException {
        try {
            exportGlobalWatchesForMember(xmlWriter,
                  DAOFactory.getMemberDAO().getMemberIDFromMemberName(memberName));
        } catch (ObjectNotFoundException e) {
            throw new ForeignKeyNotFoundException("Can't find member with name \""+memberName+"\".");
        }
    }

    public static void exportGlobalWatchesForMember(XMLWriter xmlWriter, int memberID)
    throws IOException, DatabaseException, ExportException {
        Collection globalWatches=ExportWebHelper.execSqlQuery(
                   "SELECT WatchType, WatchOption, WatchStatus, WatchCreationDate, WatchLastSentDate, WatchEndDate"+
                   " FROM "+WatchDAO.TABLE_NAME+
                   " WHERE CategoryID=0 AND ForumID=0 AND ThreadID=0"+
                   " AND MemberID="+Integer.toString(memberID));
        Iterator iter=globalWatches.iterator();
        String[] globalWatch=null;
        //try {
            xmlWriter.startElement("GlobalWatchList");
            try {
                while ( (globalWatch=(String[])iter.next()) !=null) {
                    if (globalWatch.length!=6) {
                        throw new ExportException("Error while retrieving data about global watch for memberID=="+memberID);
                    }
                    xmlWriter.startElement("GlobalWatch");
                    xmlWriter.startElement("WatchType");
                    xmlWriter.writeData(globalWatch[0]);
                    xmlWriter.endElement("WatchType");
                    xmlWriter.startElement("WatchOption");
                    xmlWriter.writeData(globalWatch[1]);
                    xmlWriter.endElement("WatchOption");
                    xmlWriter.startElement("WatchStatus");
                    xmlWriter.writeData(globalWatch[2]);
                    xmlWriter.endElement("WatchStatus");
                    xmlWriter.startElement("WatchCreationDate");
                    xmlWriter.writeData(globalWatch[3]);
                    xmlWriter.endElement("WatchCreationDate");
                    xmlWriter.startElement("WatchLastSentDate");
                    xmlWriter.writeData(globalWatch[4]);
                    xmlWriter.endElement("WatchLastSentDate");
                    xmlWriter.startElement("WatchEndDate");
                    xmlWriter.writeData(globalWatch[5]);
                    xmlWriter.endElement("WatchEndDate");
                    xmlWriter.endElement("GlobalWatch");
                }
            } catch (NoSuchElementException e) {
                //no more database records
            }
            xmlWriter.endElement("GlobalWatchList");
         //} catch throw exportexception
    }

    public static void exportMember(XMLWriter xmlWriter, String memberName)
    throws ForeignKeyNotFoundException, IOException, DatabaseException, ExportException {
        try {
            exportMember(xmlWriter,

⌨️ 快捷键说明

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