Read Log.nsf BackingBean | JavaBean

/**
 * Program: RetrieveNewNotesLogDataBackingBean.java
 * Created from Copy: 2014.01.11.11.05.AM
 * New Retrieval Classes for Log.nsf
 * 
 */

package com.dokoll.solutions.inc.search;

//...
//java imports

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import lotus.domino.Session;
import lotus.domino.View;
import lotus.domino.local.Database;
import lotus.domino.local.Document;
import com.ibm.xsp.model.domino.DominoUtils;

/**
 * 
 * @author Dököll Solutions, Inc.
 * @version 2014.01.11.11.05.AM 
 */

public class RetrieveNewNotesLogDataBackingBean {

	// Declare variable, load view name
	final String ViewName = "MiscEvents";
	// Declare variable, load logDB name
	final String ExtrnLogDB = "log.nsf";
	// Declare variable, load External ServverName
	//TODO: Figure out a better way to load the External server
	//to remove the need to hardcode serverName here...
	final String ExtrnLogSrv = "http://localhost";
	// Declare variable, load Xpages For View Page
	final String GotoPage = "xpaddnewnoteslogdata.xsp";
	// Get GetNotesLogDatesJavaBean collection
	@SuppressWarnings( { "null", "unchecked" })
	public GetNotesLogDatesJavaBean[] getNewLogKeywords() {
		// Declare GetNotesLogDatesJavaBean Array

		GetNotesLogDatesJavaBean[] logKeywords = null;

		try {

			// BEGIN DEBUG
		      System.out.println("BEGIN DEBUG | RetrieveNewNotesLogDataBackingBean.java - getNewLogKeywords started... ");
		      Session session = DominoUtils.getCurrentSession(FacesContext
						.getCurrentInstance());	
		      System.out.println("docucontent.nsf | getNewLogKeywords() in RetrieveNewNotesLogDataBackingBean.java Session Obtained..." + session);
				// find database in question from current session
				System.out.println("docucontent.nsf | getNewLogKeywords() in RetrieveNewNotesLogDataBackingBean.java finding log.nsf based on Session...");
				Database database = (Database) session.getDatabase(session.getServerName(),"log.nsf");
				System.out.println("getNewLogKeywords() in RetrieveNewNotesLogDataBackingBean.java Fetched Database..." + database);
				System.out.println("Getting a database connection... ");
		      
		      System.out.println("RetrieveNewNotesLogDataBackingBean.java | getNewLogKeywords Connected to " + database);

			// Find the view in question
			View logDBView = database.getView(ViewName);

			// load to console for debugging purposes
			System.out.println("View Obtained..." + logDBView);

			// ...
			Document sDoc;

			// ...

			Document ndoc;

			// grab our first doc

			sDoc = (Document) logDBView.getFirstDocument();

			// load to console for debugging purposes

			System.out.println("Document Obtained..." + sDoc);

			// load documents count

			logKeywords = new GetNotesLogDatesJavaBean[logDBView.getEntryCount()];

			// Run through GetNotesLogDatesJavaBean document collection

			int docount = 0;
			
			//Note: You are retrieving from Log.nsf, if you want, a copy of the DB to grab records from there
			//Rest assured however, you should have no problem running this code, you only retrieving...

			while (sDoc != null) {

				// call GetNotesLogDatesJavaBean variables will necessary
				// values...

				GetNotesLogDatesJavaBean logDatesKeyword = new GetNotesLogDatesJavaBean(
						null, null, null, null, null);

				// render document(s) to variables of Keyword object
				logDatesKeyword.setBrowserURL(ExtrnLogSrv+"/" +ExtrnLogDB + "/" + logDBView + "/"

				+ sDoc.getUniversalID() + "?OpenDocument");
				
				logDatesKeyword.setLogEvents(ExtrnLogSrv+"/" +ExtrnLogDB + "/" + GotoPage + "?" + "documentId="

						+ sDoc.getUniversalID() + "&action="+"OpenDocument");

				// Send GetNotesLogDatesJavaBean object into logKeywords Array
				logKeywords[docount] = logDatesKeyword;

				// increment counts

				docount += 1;

				// load next doc

				ndoc = (Document) logDBView.getNextDocument(sDoc);

				sDoc = ndoc;

			}

			// return the Array

			return logKeywords;

			// catch accordingly

		} catch (Exception e) {

			e.printStackTrace();

		}

		// return nothing
		return null;

	}

}//end of program...





package com.dokoll.solutions.inc.search;

/**
 * 
 * @author Dököll Solutions, Inc.
 * @version 2014.01.11.10.45.AM 
 */
public class GetNotesLogDatesJavaBean {
	
	public String LogStartDate;
	public String LogEndDate;
	public String LogServerName;
	public String LogEvents;
    public String BrowserURL;
	
	/**
	 * @return the logStartDate
	 */
	public String getLogStartDate() {
		return LogStartDate;
	}


	/**
	 * @param logStartDate the logStartDate to set
	 */
	public void setLogStartDate(String logStartDate) {
		LogStartDate = logStartDate;
	}


	/**
	 * @return the logEndDate
	 */
	public String getLogEndDate() {
		return LogEndDate;
	}


	/**
	 * @param logEndDate the logEndDate to set
	 */
	public void setLogEndDate(String logEndDate) {
		LogEndDate = logEndDate;
	}


	/**
	 * @return the logServerName
	 */
	public String getLogServerName() {
		return LogServerName;
	}


	/**
	 * @param logServerName the logServerName to set
	 */
	public void setLogServerName(String logServerName) {
		LogServerName = logServerName;
	}


	/**
	 * @return the logEvents
	 */
	public String getLogEvents() {
		return LogEvents;
	}


	/**
	 * @param logEvents the logEvents to set
	 */
	public void setLogEvents(String logEvents) {
		LogEvents = logEvents;
	}


	/**
	 * @return the browserURL
	 */
	public String getBrowserURL() {
		return BrowserURL;
	}


	/**
	 * @param browserURL the browserURL to set
	 */
	public void setBrowserURL(String browserURL) {
		BrowserURL = browserURL;
	}


	public GetNotesLogDatesJavaBean (String LogStartDate, String LogEndDate, String LogServerName, String LogEvents, String BrowserURL) {	
		this.LogStartDate = LogStartDate;
		this.LogEndDate = LogEndDate;
		this.LogServerName = LogServerName;
		this.LogEvents = LogEvents;
		this.BrowserURL = BrowserURL;
	}

}





Grab the above XSnippets to run through EventList view and perform searches on Events form in the Log.nsf back-end, info that can be used for troubleshooting errors, and so on... See Xpages file in a moment...

Java
Köll S Cherizard
January 12, 2014 3:24 PM
Rating
11

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...