本文整理汇总了Java中lotus.domino.Document.replaceItemValue方法的典型用法代码示例。如果您正苦于以下问题:Java Document.replaceItemValue方法的具体用法?Java Document.replaceItemValue怎么用?Java Document.replaceItemValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lotus.domino.Document
的用法示例。
在下文中一共展示了Document.replaceItemValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLatestMessage
import lotus.domino.Document; //导入方法依赖的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);
}
示例2: onInterval
import lotus.domino.Document; //导入方法依赖的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: setDate
import lotus.domino.Document; //导入方法依赖的package包/类
private void setDate( Document doc, String dateItemName, Date date) {
if (date==null) { return; }
DateTime dt = null;
try {
dt = getSession().createDateTime(date);
doc.replaceItemValue(dateItemName, dt);
} catch (NotesException e) {
error(e);
} finally {
try {
dt.recycle();
} catch (NotesException ne) { }
}
}
示例4: profileRemoveDelegate
import lotus.domino.Document; //导入方法依赖的package包/类
/**
* Removes a delegate from the calendar profile.
*
* @param profile
* @param delegateName
* @throws NotesException
*/
private void profileRemoveDelegate(Document profile, String delegateName) throws NotesException {
Session session = profile.getParentDatabase().getParent();
// Do for each delegate access item
for ( int i = 0; i < s_items.length; i++ ) {
// Read the item value
Vector values = profile.getItemValue(s_items[i]);
// Remove this name from the vector
for ( int j = 0; j < values.size(); j++ ) {
String strName = (String)values.get(j);
Name name = session.createName(strName);
if ( delegateName.equals(name.getAbbreviated())) {
values.remove(j);
profile.replaceItemValue(s_items[i], values);
break;
}
}
}
}
示例5: saveToDb
import lotus.domino.Document; //导入方法依赖的package包/类
public void saveToDb(Database db) throws NotesException {
Document pDoc=null;
if(isNew()) {
pDoc=db.createDocument();
pDoc.replaceItemValue("Form", "Participant");
} else {
pDoc=db.getDocumentByID(getNoteId());
}
if(isDeleted()) {
// Might not be able to delete it. So change the form.
pDoc.replaceItemValue("Form", "Participant_DELETED");
} else {
pDoc.replaceItemValue("MainDocId", getMainDocId());
pDoc.replaceItemValue("Name", getName());
pDoc.replaceItemValue("LCVFlag", isLcvProvided()?"1":"");
}
pDoc.computeWithForm(false, false);
pDoc.save();
noteId=pDoc.getNoteID();
}
示例6: createSampleDbDirProfile
import lotus.domino.Document; //导入方法依赖的package包/类
private void createSampleDbDirProfile(Database db) throws NotesException {
Document docProfile = db.getProfileDocument("DirectoryProfile", null);
docProfile.replaceItemValue("Form", "DirectoryProfile");
docProfile.replaceItemValue("Domain", db.getParent().evaluate("@Domain", docProfile));
docProfile.replaceItemValue("GroupSortDefault", "1");
docProfile.replaceItemValue("AutoPopulateMembersInterval", "30");
docProfile.replaceItemValue("SecureInetPasswords", "1");
docProfile.replaceItemValue("AltLanguageInfoAllowed", "1");
docProfile.computeWithForm(false, false);
docProfile.save(true, false);
docProfile.recycle();
}
示例7: buildMessage
import lotus.domino.Document; //导入方法依赖的package包/类
@Override
@Stopwatch(time=50)
public SocketMessage buildMessage(Document doc){
SocketMessage msg = null;
try{
RichTextItem rtitem = (RichTextItem) doc.getFirstItem(Const.FIELD_JSON);
String json = null;
if(doc.hasEmbedded()){
json = this.scanForAttachedJson(rtitem);
}else{
json = rtitem.getUnformattedText();
}
msg = JSONUtils.toObject(json, SocketMessage.class);
if(msg==null){
return new SocketMessage();//return empty invalid message.
}
}catch(Exception e){
LOG.log(Level.SEVERE,null, e);
try{
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_ERROR);
doc.replaceItemValue(Const.FIELD_ERROR, e.getMessage());
doc.save();
}catch(NotesException n){
LOG.log(Level.SEVERE,null, n);
}
}
return msg;
}
示例8: onOpenOrClose
import lotus.domino.Document; //导入方法依赖的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.Document; //导入方法依赖的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: buildDirectMessages
import lotus.domino.Document; //导入方法依赖的package包/类
/**
* Builds the direct messages.
*
* @param doc the doc
*/
@Stopwatch
private void buildDirectMessages(Document doc) {
Document directMessage=null;
try{
for(String server : this.getClusterMates(doc.getParentDatabase().getParent())){
directMessage = doc.copyToDatabase(doc.getParentDatabase());
directMessage.replaceItemValue(Const.FIELD_TO, server);
directMessage.save();
directMessage.recycle();
}
}catch(Exception e){
LOG.log(Level.SEVERE,null, e);
try {
doc.replaceItemValue(Const.FIELD_ERROR, e.getLocalizedMessage());
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_ERROR);
doc.save();
directMessage.replaceItemValue(Const.FIELD_ERROR, e.getLocalizedMessage());
directMessage.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_ERROR);
directMessage.save();
} catch (NotesException e1) {
LOG.log(Level.SEVERE,null, e);
}
}
}
示例11: processDoc
import lotus.domino.Document; //导入方法依赖的package包/类
/**
* Process doc.
*
* @param doc the doc
*/
//@Stopwatch(time=50)
protected void processDoc(Document doc){
try{
ServerInfo info = ServerInfo.getInstance();
String to = doc.getItemValueString(Const.FIELD_TO);
IUser user = server.resolveUser(to);
//only process if we're on the correct host, and that the user has an open connection.
if((to.startsWith(StringCache.FORWARD_SLASH)
|| info.isCurrentServer(to)
|| (user!=null && user.isOpen()
&& user.isOnServer()))){
//validate the fields
SocketMessage msg = msgFactory.buildMessage(doc);
//validate the data was bound correctly.
if(msg.isValid()){
boolean b = server.onMessage(to, msg.toJson());
if(b){
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_SENT);
doc.save();
}
}else{
doc.replaceItemValue(Const.FIELD_SENTFLAG, Const.FIELD_SENTFLAG_VALUE_ERROR);
doc.replaceItemValue(Const.FIELD_ERROR, "Invalid message. Please check field data.");
doc.save();
}
}
}catch(Exception e){
LOG.log(Level.SEVERE,null, e);
}
}
示例12: flagForDeletion
import lotus.domino.Document; //导入方法依赖的package包/类
/**
* Flag for deletion.
*
* @param doc the doc
* @throws NotesException the notes exception
*/
private void flagForDeletion(Document doc) throws NotesException{
doc.removeItem(StringCache.FIELD_REF);
doc.removeItem(StringCache.FIELD_CONFLICT);
doc.replaceItemValue(StringCache.FIELD_FORM, Const.FIELD_VALUE_DELETE);
doc.save();
}
示例13: setClustermateUsersOffline
import lotus.domino.Document; //导入方法依赖的package包/类
/**
* Sets the clustermate users offline.
*
* @param db the db
* @param clustermate the clustermate
*/
@Stopwatch
private void setClustermateUsersOffline(Database db, String clustermate) {
try {
View view = db.getView(Const.VIEW_USERS);
view.setAutoUpdate(false);
Document doc = view.getFirstDocument();
Document temp = null;
while(doc!=null){
if(doc.isValid()){
String host = doc.getItemValueString(Const.FIELD_HOST);
//if hosts are the same
if(host!=null && host.equals(clustermate)){
doc.replaceItemValue(Const.FIELD_STATUS, Const.STATUS_OFFLINE);
doc.save();
}
}
temp = view.getNextDocument(doc);
doc.recycle();
doc = temp;
}
view.setAutoUpdate(true);
} catch (NotesException e) {
LOG.log(Level.SEVERE,null,e);
}
}
示例14: run
import lotus.domino.Document; //导入方法依赖的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);
}
}
示例15: getStoreDoc
import lotus.domino.Document; //导入方法依赖的package包/类
private Document getStoreDoc() {
Database database=ExtLibUtil.getCurrentDatabase();
Document doc=null;
View view=null;
try {
view=database.getView("tokenstores");
String serverName=database.getServer();
doc=view.getDocumentByKey(serverName, true);
if(doc==null) {
doc=database.createDocument();
doc.replaceItemValue("Form", "tokenstore");
doc.replaceItemValue("ServerName", serverName);
doc.computeWithForm(false, false);
doc.save();
}
} catch (NotesException e) {
e.printStackTrace();
} finally {
DevelopiUtils.recycleObject(view);
}
return doc;
}