本文整理汇总了Java中lotus.domino.Database类的典型用法代码示例。如果您正苦于以下问题:Java Database类的具体用法?Java Database怎么用?Java Database使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Database类属于lotus.domino包,在下文中一共展示了Database类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAppstore
import lotus.domino.Database; //导入依赖的package包/类
private void loadAppstore() {
Database db=ExtLibUtil.getCurrentDatabase();
View view=null;
Document appstore=null;
try {
view=db.getView("apps");
appstore=view.getDocumentByKey(DEFAULT_ENDPOINT_NAME, true);
if(appstore==null) {
System.out.println("No Application found for "+DEFAULT_ENDPOINT_NAME);
} else {
consumerKey=appstore.getItemValueString("ConsumerKey");
consumerSecret=appstore.getItemValueString("ConsumerSecret");
}
} catch(NotesException ne) {
ne.printStackTrace();
} finally {
DevelopiUtils.recycleObjects(appstore, view);
}
}
示例2: getLatestMessage
import lotus.domino.Database; //导入依赖的package包/类
@Override
public Response getLatestMessage() throws NotesException {
if(this.hasWebSocketConnection()){
throw new RuntimeException("This RESTful API can only be used when no websocket connection is open.");
}
SocketMessage msg = null;
Database db = XSPUtils.session().getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_MESSAGES_BY_USER);
ViewEntry entry = view.getEntryByKey(XSPUtils.session().getEffectiveUserName(),true);
if(entry!=null){
Document doc = entry.getDocument();
if(doc.isValid()){
msg = msgFactory.buildMessage(entry.getDocument());
//mark as sent.
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_SENT);
doc.save();
}
}
//cleanup db should cleanup view, entry, and doc.
db.recycle();
return this.buildResponse(msg);
}
示例3: getSampleDataViewsDb
import lotus.domino.Database; //导入依赖的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;
}
示例4: testNamesListCreation_listComparisonWithLegacy
import lotus.domino.Database; //导入依赖的package包/类
public void testNamesListCreation_listComparisonWithLegacy() {
runWithSession(new IDominoCallable<Object>() {
@Override
public Object call(Session session) throws Exception {
NotesDatabase dbData = getFakeNamesDb();
Database dbLegacyAPI = session.getDatabase(dbData.getServer(), dbData.getRelativeFilePath());
List<String> userNamesListJNA = NotesNamingUtils.getUserNamesList(session.getEffectiveUserName());
Assert.assertTrue("JNA names list contains the current username", userNamesListJNA.contains(session.getEffectiveUserName()));
Vector<Name> userGroupNamesList = session.getUserGroupNameList();
for (Name currNameLegacy : userGroupNamesList) {
Assert.assertTrue("JNA list contains "+currNameLegacy.getCanonical(), userNamesListJNA.contains(currNameLegacy.getCanonical()));
}
Name currUserName = session.getUserNameObject();
Assert.assertTrue("JNA usernames list contains "+currUserName.getCanonical(), userNamesListJNA.contains(currUserName.getCanonical()));
Assert.assertTrue("JNA usernames list contains "+currUserName.getCommon(), userNamesListJNA.contains(currUserName.getCanonical()));
Assert.assertTrue("JNA usernames list contains *", userNamesListJNA.contains("*"));
return null;
}
});
}
示例5: testViewMetaData_nameAndAlias
import lotus.domino.Database; //导入依赖的package包/类
@Test
public void testViewMetaData_nameAndAlias() {
runWithSession(new IDominoCallable<Object>() {
@Override
public Object call(Session session) throws Exception {
NotesDatabase dbData = getFakeNamesDb();
Database dbDataLegacy = getFakeNamesDbLegacy();
//CompaniesHierarchical
NotesCollection colFromDbData = dbData.openCollectionByName("AnotherAlias");
View viewCompanies = dbDataLegacy.getView("AnotherAlias");
Assert.assertEquals("Name correct", viewCompanies.getName(), colFromDbData.getName());
Assert.assertEquals("Aliases correct", viewCompanies.getAliases(), colFromDbData.getAliases());
Assert.assertEquals("Selection formula correct", viewCompanies.getSelectionFormula(), colFromDbData.getSelectionFormula());
return null;
}
});
}
示例6: testViewMetaData_columnTitleLookup
import lotus.domino.Database; //导入依赖的package包/类
@Test
public void testViewMetaData_columnTitleLookup() {
runWithSession(new IDominoCallable<Object>() {
@Override
public Object call(Session session) throws Exception {
NotesDatabase dbData = getFakeNamesDb();
Database dbDataLegacy = getFakeNamesDbLegacy();
NotesCollection colFromDbData = dbData.openCollectionByName("People");
colFromDbData.update();
View viewPeople = dbDataLegacy.getView("People");
int topLevelEntriesLegacy = viewPeople.getTopLevelEntryCount();
int topLevelEntries = colFromDbData.getTopLevelEntries();
System.out.println("Top level entries: "+topLevelEntries);
Assert.assertEquals("Top level entries of JNA call is equal to legacy call", topLevelEntriesLegacy, topLevelEntries);
return null;
}
});
}
示例7: testDbGetAccess
import lotus.domino.Database; //导入依赖的package包/类
@Test
public void testDbGetAccess() {
runWithSession(new IDominoCallable<Object>() {
@Override
public Object call(Session session) throws Exception {
NotesDatabase dbData = getFakeNamesDb();
Database dbLegacy = getFakeNamesDbLegacy();
AccessInfoAndFlags accessInfo = dbData.getAccessInfoAndFlags();
AclLevel aclLevel = accessInfo.getAclLevel();
EnumSet<AclFlag> aclFlags = accessInfo.getAclFlags();
int legacyAclLevel = dbLegacy.queryAccess(session.getEffectiveUserName());
Assert.assertEquals("ACL level is the same", aclLevel.getValue(), legacyAclLevel);
System.out.println("Access level: "+accessInfo.getAclLevel());
System.out.println("Access flags: "+accessInfo.getAclFlags());
return null;
}
});
}
示例8: testDbGetACL
import lotus.domino.Database; //导入依赖的package包/类
@Test
public void testDbGetACL() {
runWithSession(new IDominoCallable<Object>() {
@Override
public Object call(Session session) throws Exception {
NotesDatabase dbData = getFakeNamesDb();
Database dbLegacy = getFakeNamesDbLegacy();
AccessInfoAndFlags accessInfo = dbData.getAccessInfoAndFlags();
System.out.println("Access level: "+accessInfo.getAclLevel());
System.out.println("Access flags: "+accessInfo.getAclFlags());
NotesACL acl = dbData.getACL();
NotesACLAccess aclAccess = acl.lookupAccess(IDUtils.getCurrentUsername());
Assert.assertEquals("ACL level is equal", accessInfo.getAclLevel(), aclAccess.getAclLevel());
Assert.assertEquals("ACL flags are equal", accessInfo.getAclFlags(), aclAccess.getAclFlags());
Assert.assertEquals("ACL roles are equal", dbLegacy.queryAccessRoles(session.getEffectiveUserName()),
aclAccess.getRoles());
return null;
}
});
}
示例9: isAuthorized
import lotus.domino.Database; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean isAuthorized(String[] rolesAllowed) {
boolean b = false;
try{
Session s= XSPUtils.session();
Database db = XSPUtils.database();
if(s!=null && db!=null){
Vector<String> roles = db.queryAccessRoles(s.getEffectiveUserName());
for(String role : rolesAllowed){
if(roles.contains(role)){
b = true;
break;
}
}
}
}catch(NotesException n){
n.printStackTrace();
}
return b;
}
示例10: getMessages
import lotus.domino.Database; //导入依赖的package包/类
@Override
public Response getMessages() throws NotesException {
if(this.hasWebSocketConnection()){
throw new RuntimeException("This RESTful API can only be used when no websocket connection is open.");
}
Database db = XSPUtils.session().getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
View view = db.getView(Const.VIEW_MESSAGES_BY_USER);
ViewEntryCollection col = view.getAllEntriesByKey(XSPUtils.session().getEffectiveUserName(),true);
List<SocketMessage> list = msgFactory.buildMessages(col);
//mark the collection as sent
col.stampAll(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_SENT);
//cleanup db should cleanup view, and col
db.recycle();
return this.buildResponse(list);
}
示例11: onInterval
import lotus.domino.Database; //导入依赖的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);
}
}
示例12: getUserDoc
import lotus.domino.Database; //导入依赖的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;
}
示例13: deleteAnonymousDoc
import lotus.domino.Database; //导入依赖的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();
}
}
示例14: stampDocuments
import lotus.domino.Database; //导入依赖的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);
}
}
示例15: removeDocuments
import lotus.domino.Database; //导入依赖的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);
}
}