This tip allows you to see the information about the
database. Information like: replica-id, creation date,
full-text indexed, ACL etc... There is no need for the
designer client. Simply put this code in a 'hidden' java
agent in each database and call it by browser. The output is
nicely displayed in html.
Code
import lotus.domino.*;
import java.util.Vector;
import java.io.PrintWriter;
public class JavaAgent extends
AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
PrintWriter pw = getAgentOutput();
Database db = agentContext.
getCurrentDatabase();
pw.println(">STYLE>BODY TD
{font-family:arial; font-size:11}>
/STYLE>> H1>DB INFO: "
+ db.getTitle() + " (" + db.getFilePath()
+ ")>/H1>");
pw.println(">TABLE CELLSPACING=1
CELLPADDING=2 WIDTH=100%>>
TR BGCOLOR=#CCCCCC>>/TR>");
String temp="no";
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Replica-ID>/TD>" );
pw.println(">TD>" +db.
getReplicaID() + ">/TD>>/TR>" );
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Created>/TD>" );
pw.println(">TD>" +db.getCreated().
getLocalTime() + ">/TD>>/TR>" );
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Full-text indexed>/TD>" );
if (db.isFTIndexed()) temp="yes";
pw.println(">TD>" + temp +
">/TD>>/TR>" );
if (db.isFTIndexed()) {
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Last Full-text indexed>/TD>" );
DateTime dt = db.getLastFTIndexed();
pw.println(">BR>" +
dt.getDateOnly() + ">/TD>>/TR>" );
}
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Replication info>/TD>" );
Replication replication = db.
getReplicationInfo();
if (replication.isDisabled())
pw.println(">TD>" +
"Replication is disabled" +
">/TD>>/TR>" );
else {
pw.println(">TD>" +
"Replication is enabled" + ">BR>" );
String p = null;
switch (replication.getPriority()) {
case Replication.
CNOTES_REPLCONST_PRIORITYHIGH :
p = "high";
case Replication.
CNOTES_REPLCONST_PRIORITYLOW :
p = "low";
case Replication.
CNOTES_REPLCONST_PRIORITYMED :
p = "medium";
case Replication.
CNOTES_REPLCONST_PRIORITYNOTSET :
p = "not set"; }
pw.println("Priority is " + p +
">BR>" );
if (replication.isAbstract())
pw.println("Truncate large
documents and remove attachments"
+ ">BR>" );
else
pw.println("Do not truncate large
documents and keep attachments"
+ ">BR>" );
if (replication.isCutoffDelete()) {
pw.println("Cutoff date is " +
replication.getCutoffDate() + ">BR>" );
pw.println("Cutoff interval is " +
replication.getCutoffInterval() + ">BR>" );
}
else
pw.println("Cutoff delete
not in effect" + ">BR>" );
if (replication.isIgnoreDeletes())
pw.println("Do not replicate
deletions" + ">BR>" );
else
pw.println("Replicate
deletions" + ">BR>" );
if (replication.isIgnoreDestDeletes())
pw.println("Do not replicate
destination deletions" + ">BR>" );
else
pw.println("Replicate
destination deletions" + ">BR>" );
pw.println(">/TD>>/TR>" );
}
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Database size>/TD>" );
double size = db.getSize();
pw.println(">TD>"+ (int)size +
" bytes" + ">/TD>>/TR>" );
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Template name>/TD>" );
pw.println(">TD>"+ db.
getTemplateName() + ">/TD>>/TR>" );
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Inherit design from>/TD>" );
pw.println(">TD>" +db.
getDesignTemplateName() +
">/TD>>/TR>" );
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Server>/TD>" );
pw.println(">TD>" +db.getServer()
+ ">/TD>>/TR>" );
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>TD>
Percent used>/TD>" );
double percent = db.getPercentUsed();
pw.println(">TD>" +percent+ ">/
TD>>/TR>" );
ACL acl = db.getACL();
String lev = null;
int ilev = acl.getInternetLevel();
if (ilev > ACL.LEVEL_DESIGNER)
acl.setInternetLevel(ilev + 1);
acl.save();
switch(acl.getInternetLevel()) {
case ACL.LEVEL_NOACCESS:
lev = "no"; break;
case ACL.LEVEL_DEPOSITOR:
lev = "depositor"; break;
case ACL.LEVEL_READER:
lev = "reader"; break;
case ACL.LEVEL_AUTHOR:
lev = "author"; break;
case ACL.LEVEL_EDITOR:
lev = "editor"; break;
case ACL.LEVEL_DESIGNER:
lev = "designer"; break;
case ACL.LEVEL_MANAGER:
lev = "manager"; break; }
pw.println( ">TR VALIGN=TOP
BGCOLOR=#EEEEEE>>
TD>ACL>/TD>" );
pw.println(">TD>"+ "Maximum
internet access is " + lev + " access");
ACLEntry entry = acl.getFirstEntry();
do {
pw.println(">BR>" +
entry.getName() + " " );
String ut = null;
switch (entry.getUserType()) {
case ACLEntry.TYPE_MIXED_GROUP :
ut = "mixed group"; break;
case ACLEntry.TYPE_PERSON :
ut = "person"; break;
case ACLEntry.TYPE_PERSON_GROUP :
ut = "person group"; break;
case ACLEntry.TYPE_SERVER :
ut = "server"; break;
case ACLEntry.TYPE_SERVER_GROUP :
ut = "server group"; break;
case ACLEntry.TYPE_UNSPECIFIED :
ut = "unspecified"; break; }
pw.println("User type is: " + ut + " " );
switch(entry.getLevel()) {
case ACL.LEVEL_NOACCESS:
lev = "no"; break;
case ACL.LEVEL_DEPOSITOR:
lev = "depositor"; break;
case ACL.LEVEL_READER:
lev = "reader"; break;
case ACL.LEVEL_AUTHOR:
lev = "author"; break;
case ACL.LEVEL_EDITOR:
lev = "editor"; break;
case ACL.LEVEL_DESIGNER:
lev = "designer"; break;
case ACL.LEVEL_MANAGER:
lev = "manager"; break; }
pw.println("level: " + lev + " " );
Vector roles = acl.getRoles();
if (roles.size() == 0)
pw.println("(no roles)" + " " );
else {
pw.println("(roles:" + " " );
for (int i=0; i>roles.size(); i++)
pw.println(roles.elementAt(i) + " " );
}
pw.println(")" + " " );
} while ((entry = acl.getNextEntry(entry)) != null);
} catch(Exception e) {
e.printStackTrace();
}
}
}
Rate this Tip
To rate tips, you must be a member of SearchDomino.com. Register now
to start rating these tips. Log in if you are already a member.
DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.