本文整理汇总了Java中lotus.domino.Session.getDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getDatabase方法的具体用法?Java Session.getDatabase怎么用?Java Session.getDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lotus.domino.Session
的用法示例。
在下文中一共展示了Session.getDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSampleDataViewsDb
import lotus.domino.Session; //导入方法依赖的package包/类
public synchronized NotesDatabase getSampleDataViewsDb() throws NotesException {
Session session = getSession();
NotesDatabase db;
try {
db = new NotesDatabase(session, "", DBPATH_SAMPLEDATA_VIEWS_NSF);
return db;
}
catch (NotesError e) {
if (e.getId() != 259) { // file does not exist
throw e;
}
}
System.out.println("Looks like our sample database "+DBPATH_SAMPLEDATA_VIEWS_NSF+" to test private views does not exist. We will now (re)create it.");
Database dbSampleDataLegacy = session.getDatabase("", DBPATH_SAMPLEDATA_NSF, true);
Database dbSampleDataViewsLegacy = dbSampleDataLegacy.createFromTemplate("", DBPATH_SAMPLEDATA_VIEWS_NSF, true);
createSampleDbDirProfile(dbSampleDataViewsLegacy);
dbSampleDataLegacy.recycle();
dbSampleDataViewsLegacy.recycle();
db = new NotesDatabase(session, "", DBPATH_SAMPLEDATA_VIEWS_NSF);
db.setTitle("Domino JNA testcase views");
return db;
}
示例2: onInterval
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* On interval.
*/
private void onInterval(){
Session session = null;
try{
session = this.openSession();
Database db = session.getDatabase(StringCache.EMPTY, dbPath());
Document doc = db.createDocument();
doc.replaceItemValue(FUNCTION, Const.ON_MESSAGE);
doc.replaceItemValue(EVENT, Const.ON_INTERVAL);
Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
agent.runWithDocumentContext(doc);
}catch(NotesException n){
LOG.log(Level.SEVERE, null, n);
}finally{
this.closeSession(session);
}
}
示例3: getUserDoc
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* Gets the user doc.
*
* @param session the session
* @param create the create
* @return the user doc
* @throws NotesException the notes exception
*/
private Document getUserDoc(Session session, boolean create) throws NotesException{
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
Document doc = null;
View users = db.getView(Const.VIEW_USERS);
View sessions = db.getView(Const.VIEW_SESSIONS);
doc = users.getDocumentByKey(user.getUserId().trim(),true);
if(doc == null){
doc = sessions.getDocumentByKey(user.getSessionId(),true);
}
//if we get here... create the doc.
if(doc==null && create){
doc = db.createDocument();
}
//cleanup
users.recycle();
sessions.recycle();
return doc;
}
示例4: deleteAnonymousDoc
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* Delete anonymous doc.
*
* @param session the session
* @throws NotesException the notes exception
*/
//if the user moved from anonymous to person to anonymous to person
private void deleteAnonymousDoc(Session session) throws NotesException{
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_USERS);
Vector<String> keys = new Vector<String>(3);
keys.add(this.getSessionId().trim());
keys.add(this.getSessionId().trim());
DocumentCollection col = view.getAllDocumentsByKey(keys,true);
if(col!=null && col.getCount() > 0){
col.stampAll(Const.FIELD_FORM, Const.FIELD_VALUE_DELETE);
col.recycle();
}
}
示例5: stampDocuments
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* Stamp documents.
*
* @param search the search
* @param field the field
* @param value the value
*/
public void stampDocuments(String search, String field, Object value){
Session session = this.openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
DocumentCollection col = db.search(search);
if(col!=null && col.getCount() > 0){
col.stampAll(field, value);
col.recycle();
}
//cleanup
db.recycle();
} catch (NotesException e) {
if(!e.text.contains("No documents were categorized")){
LOG.log(Level.SEVERE,null,e);
}
}finally{
closeSession(session);
}
}
示例6: removeDocuments
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* Removes the documents.
*
* @param search the search
*/
public void removeDocuments(String search){
Session session = openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
DocumentCollection col = db.search(search);
if(col!=null && col.getCount() > 0){
col.removeAll(true);
col.recycle();
}
//cleanup
db.recycle();
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
closeSession(session);
}
}
示例7: extractFile
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* Extract file.
*
* @return the string
*/
public synchronized String extractFile(){
Session session = null;
String script = null;
try{
session = this.openSession();
Database db = session.getDatabase(StringCache.EMPTY, this.dbPath());
if(!db.isOpen()){
db.open();
}
byte[] byteMe = DxlUtils.findFileResource(db, this.getResource());
script = new String(byteMe, cfg.getCharSet());
//resolve dependencies.
script = new ScriptAggregator(db).build(script);
}catch(NotesException n){
LOG.log(Level.SEVERE, "notes error " + n.text + " " + this.dbPath());
LOG.log(Level.SEVERE, null, n);
}catch(Exception e){
LOG.log(Level.SEVERE, "error resolving file using path " + this.dbPath());
LOG.log(Level.SEVERE, null, e);
}finally{
this.closeSession(session);
}
return script;
}
示例8: onOpenOrClose
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* On open or close.
*
* @param fun the fun
*/
private void onOpenOrClose(String fun){
Session session = null;
try{
session = this.openSession();
Database db = session.getDatabase(StringCache.EMPTY, dbPath());
Document doc = db.createDocument();
IUser user = (IUser) this.args[0];
doc.replaceItemValue("userId",user.getUserId());
doc.replaceItemValue("sessionId",user.getSessionId());
doc.replaceItemValue("host",user.getHost());
doc.replaceItemValue("status",user.getStatus());
doc.replaceItemValue("uris",ColUtils.toVector(user.getUris()));
doc.replaceItemValue(FUNCTION, fun);
RichTextItem item = doc.createRichTextItem("Body");
item.appendText(JSONUtils.toJson(user));
doc.replaceItemValue("Form", user.getClass().getName());
Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
agent.runWithDocumentContext(doc);
}catch(NotesException n){
LOG.log(Level.SEVERE, null, n);
}finally{
this.closeSession(session);
}
}
示例9: onMessage
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* On message.
*/
private void onMessage(){
Session session = null;
try{
session = this.openSession();
Database db = session.getDatabase(StringCache.EMPTY, dbPath());
Document doc = db.createDocument();
SocketMessage msg = (SocketMessage) this.args[0];
doc.replaceItemValue(FUNCTION, Const.ON_MESSAGE);
doc.replaceItemValue("from", msg.getFrom());
doc.replaceItemValue("to", msg.getTo());
doc.replaceItemValue("text", msg.getText());
doc.replaceItemValue(EVENT, Const.ON_MESSAGE);
doc.replaceItemValue("targets", ColUtils.toVector(msg.getTargets()));
RichTextItem item = doc.createRichTextItem("Body");
item.appendText(msg.toJson());
doc.replaceItemValue("Form", SocketMessage.class.getName());
Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
agent.runWithDocumentContext(doc);
}catch(NotesException n){
LOG.log(Level.SEVERE, null, n);
}finally{
this.closeSession(session);
}
}
示例10: getClusterMates
import lotus.domino.Session; //导入方法依赖的package包/类
/**
* Gets the cluster mates.
*
* @param s the s
* @return the cluster mates
* @throws NotesException the notes exception
*/
private List<String> getClusterMates(Session s) throws NotesException{
if(clusterMates.isEmpty()){
synchronized(clusterMates){
if(clusterMates.isEmpty()){
if(!Config.getInstance().isClustered()){
clusterMates.add(ServerInfo.getInstance().getServerName());
return clusterMates;
}
System.out.println("loading clustermates");
/*
* all below should get recycled after session is recycled.
*/
final Database db = s.getDatabase(StringCache.EMPTY, StringCache.NAMES_DOT_NSF);
final View view = db.getView(Const.VIEW_SERVERS);
final Document docServer = view.getDocumentByKey(ServerInfo.getInstance().getServerName(), true);
final String clusterName = docServer.getItemValueString(Const.FIELD_CLUSTERNAME);
final DocumentCollection col = db.getView(Const.VIEW_CLUSTERS).getAllDocumentsByKey(clusterName,true);
Document doc = col.getFirstDocument();
while(doc!=null){
clusterMates.add(doc.getItemValueString(Const.FIELD_SERVERNAME));
doc = col.getNextDocument(doc);
}
}
}
}
return clusterMates;
}
示例11: run
import lotus.domino.Session; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
if(TaskRunner.getInstance().isClosing()){
return;
}
//exit if nobody on.
if(server.getWebSocketCount() == 0) return;
Session session = this.openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(this.getEventQueue());
view.setAutoUpdate(false);
DocumentCollection col = view.getAllDocumentsByKey(target, true);
Document doc = col.getFirstDocument();
Document temp = null;
while(doc!=null){
if(doc.isValid()){
this.processDoc(doc);
}
temp = col.getNextDocument(doc);
doc.recycle();
doc = temp;
}
view.setAutoUpdate(true);
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
this.closeSession(session);
}
}
示例12: run
import lotus.domino.Session; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
if(TaskRunner.getInstance().isClosing()){
return;
}
if(server.getWebSocketAndObserverCount() == 0)return;
Session session = this.openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_MSG_QUEUE);
if(view.getAllEntries().getCount() > 0){
view.setAutoUpdate(false);
Document doc = view.getFirstDocument();
Document temp = null;
while(doc!=null){
if(doc.isValid() && !doc.hasItem(StringCache.FIELD_CONFLICT)){
this.processDoc(doc);
}else if(doc.isValid() && doc.hasItem(StringCache.FIELD_CONFLICT)){
this.processConflict(doc);
}
temp = view.getNextDocument(doc);
doc.recycle();
doc = temp;
}
view.setAutoUpdate(true);
}
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
this.closeSession(session);
}
}
示例13: run
import lotus.domino.Session; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
if(TaskRunner.getInstance().isClosing()){
return;
}
Session session = this.openSession();
try {
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_USERS);
Document doc = view.getFirstDocument();
Document temp = null;
while(doc!=null){
String host = doc.getItemValueString(Const.FIELD_HOST);
if(ServerInfo.getInstance().isCurrentServer(host)){
String currentStatus= doc.getItemValueString(Const.FIELD_STATUS);
//only update if we need to.
if(!this.getStatus().equals(currentStatus)){
doc.replaceItemValue(Const.FIELD_STATUS, this.getStatus());
doc.save();
}
}
temp = view.getNextDocument(doc);
doc.recycle();
doc = temp;
}
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
SessionFactory.closeSession(session);
}
}
示例14: run
import lotus.domino.Session; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
if(TaskRunner.getInstance().isClosing()){
return;
}
//exit if nobody on.
if(server.getWebSocketCount() == 0) return;
Session session = super.openSession();
try {
if(ServerInfo.getInstance().isCurrentServer(Config.getInstance().getBroadcastServer())){
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_BROADCAST_QUEUE);
view.setAutoUpdate(false);
Document doc = view.getFirstDocument();
Document temp = null;
while(doc!=null){
if(doc.isValid() && !doc.hasItem(StringCache.FIELD_CONFLICT)){
this.buildDirectMessages(doc);
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_SENT);
doc.save();
}
temp = view.getNextDocument(doc);
doc.recycle();
doc = temp;
}
view.setAutoUpdate(true);
}
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
super.closeSession(session);
}
}
示例15: run
import lotus.domino.Session; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
if(TaskRunner.getInstance().isClosing()){
return;
}
//if the message has already been persisted don't process it again.
if(!msg.isPersisted()){
Session session = this.openSession();
try {
//mark object as persisted so we don't keep persisting.
msg.setPersisted(true);
Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
Document doc = db.createDocument();
doc.replaceItemValue("Form", "fmSocketMessage");
doc.replaceItemValue("text", msg.getText());
doc.replaceItemValue("to", msg.getTo());
doc.replaceItemValue("from", msg.getFrom());
doc.replaceItemValue("event", StringCache.EMPTY);
doc.replaceItemValue("durable", String.valueOf(msg.isDurable()));
doc.replaceItemValue("persisted", String.valueOf(msg.isPersisted()));
this.attach(doc, msg);
db.recycle();
doc.recycle();
} catch (NotesException e) {
LOG.log(Level.SEVERE,null, e);
}finally{
this.closeSession(session);
}
}
}