private void exportBlogposts()

in src/main/java/com/atlassian/uwc/exporters/JiveExporter.java [677:770]


	private void exportBlogposts() {
		if (!this.running) return;
		log.debug("Exporting Blogs");
		if (this.sqlStatements.containsKey("sql.blog")) {
			int commentIndex = 0;
			int attachmentIndex = 0;
			String sqlStatement = this.sqlStatements.get("sql.blog");
			try {
				ResultSet blogResults = sql(sqlStatement);
				//get the count data
				blogResults.last();
				int maxBlogs = blogResults.getRow();
				blogResults.beforeFirst();
				if (maxBlogs > 0) testString += "Count: " + maxBlogs + "\n";
				// go through the results for each page version
				int index = 0;
				String lastfile = "";
				Vector<Long> noResultsIds = new Vector<Long>();
				while (blogResults.next()) {
					if (!this.running) return;
					long blogpostId = blogResults.getLong("blogpostID");
					long blogId = blogResults.getLong("blogID");
					int containerType = blogResults.getInt("containerType");
					long containerId = blogResults.getLong("containerId");
					String usercontainername = (containerType == 2020)?getUserContainerName(containerId):null;
					
					if (!fromAllowedContainer(containerId, containerType)) {
						maxBlogs--;
						continue;
					}
					
					long userid = blogResults.getLong("userId");
					String username = ((userid > 0)?getUsername(userid):userid+"");
					String title = blogResults.getString("subject");
					String body = blogResults.getString("body");
					long creationDate = blogResults.getLong("creationDate");
					long modificationDate = blogResults.getLong("modificationDate");
					int versionId = 1;
					String tags = getTags(blogpostId, BLOG_JIVECONSTANT);

					if (this.debug && tags != null) {
						testString += blogpostId + ": " + tags + "\n";
					}
					else if (this.debug) {
						testString += "|" + blogpostId + "|" + blogId + "|" + 
						containerType + "|" + containerId + "|" +
						(usercontainername==null?"":usercontainername.substring(0,2)) + "|" + 
						username.substring(0,2) + "|" +
						title.substring(0,1) + "|" + ((body != null)?"BODY":"") + "|\n" ;
					}
					else {
						String contentType = "BLOG";
						String expdir = getExportPath(this.outdir);
						String containerdir = createContainerDir(expdir, containerType, containerId);
						String filename = createFilename(blogpostId, versionId, contentType, title);
						String filepath = expdir + containerdir + filename;
						String content = createPageContent(blogpostId, versionId, contentType, title,
								containerType, containerId,
								username, usercontainername, 
								creationDate, modificationDate, body, tags);
						lastfile = filepath;
						writeFile(filepath, content, this.encoding); 
						
						//export title data (we'll need this in a seperate map file for links and attachments to other pages)
						title = getDate(modificationDate) + title;
						exportTitles(blogpostId, BLOG_JIVECONSTANT, containerId, containerType, versionId, title);
					}
					//export comments
					commentIndex += exportComments(blogpostId,
							containerType, containerId, "blog");
					
					attachmentIndex += exportAttachments(blogpostId, BLOG_JIVECONSTANT);
					
					//do some logging
					index++;
					if ((index % 100) == 0) {
						double percent = Math.round(100*(((double) index)/maxBlogs));
						log.debug("Exporting " + index + " Blogs. " + percent + "%");
					}
				}
				log.info("Exporting " + index + " Blogs. 100.0%");
				log.info("Exported " + commentIndex + " comments for blogs.");
				log.info("Exported data for " + attachmentIndex + " attachments.");
				log.debug("Lastfile = " + lastfile);
				if (this.debug) {
					testString += "Final Count: " + index;
					writeFile(this.debugOutFile, testString, this.encoding);
				}
			} catch (SQLException e) {
				log.error("Problem getting blogs: " + sqlStatement, e);
				return;
			}
		}
	}