本文整理汇总了Java中lotus.domino.Document类的典型用法代码示例。如果您正苦于以下问题:Java Document类的具体用法?Java Document怎么用?Java Document使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Document类属于lotus.domino包,在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAppstore
import lotus.domino.Document; //导入依赖的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.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);
}
示例3: createUser
import lotus.domino.Document; //导入依赖的package包/类
@Override
public IUser createUser(Document doc) {
IUser user = guicer.createObject(IUser.class);
try {
user.setConn(null); // conn should be null, user is on a different server in the cluster.
user.setDate(doc.getCreated().toJavaDate());
user.setGoingOffline(false);
user.setHost(doc.getItemValueString(Const.FIELD_HOST));
user.setSessionId(doc.getItemValueString(Const.FIELD_SESSIONID));
user.setStatus(doc.getItemValueString(Const.FIELD_STATUS));
user.setUserId(doc.getItemValueString(Const.FIELD_USERID));
} catch (NotesException e) {
LOG.log(Level.SEVERE,null, e);
}
return user;
}
示例4: 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);
}
}
示例5: getUserDoc
import lotus.domino.Document; //导入依赖的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;
}
示例6: attach
import lotus.domino.Document; //导入依赖的package包/类
/**
* Attach.
*
* @param doc the doc
* @param msg the msg
*/
private void attach(Document doc, SocketMessage msg){
File file = JSONUtils.write(msg);
try{
RichTextItem rtitem = doc.createRichTextItem("json");
EmbeddedObject eo = rtitem.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, file.getAbsolutePath(), Const.ATTACH_NAME);
doc.save();
//cleanup.
eo.recycle();
rtitem.recycle();
}catch(Exception e){
LOG.log(Level.SEVERE,null,e);
}finally{
if(file!=null && file.exists()){
file.delete();
}
}
}
示例7: processConflict
import lotus.domino.Document; //导入依赖的package包/类
/**
* Process conflict.
*
* @param doc the doc
* @throws NotesException the notes exception
*/
//latest one in wins.
protected void processConflict(Document doc) throws NotesException{
Document parent = doc.getParentDatabase().getDocumentByUNID(doc.getParentDocumentUNID());
Document winner = null;
if(parent.getCreated().toJavaDate().before(doc.getCreated().toJavaDate())){
winner = doc;
this.flagForDeletion(parent);
}else{
winner = parent;
this.flagForDeletion(doc);
}
winner.removeItem(StringCache.FIELD_CONFLICT);
winner.removeItem(StringCache.FIELD_REF);
winner.save();
}
示例8: readDocument
import lotus.domino.Document; //导入依赖的package包/类
public void readDocument (Document doc){
Vector<Item> items;
try {
items = doc.getItems();
Form form = doc.getParentDatabase().getForm(doc.getItemValueString("Form"));
Vector<String> fields = form.getFields();
for(Item item : items){
String fieldName = this.resolveFieldName(item.getName(), fields);
this.processItem(item, fieldName);
}
//make sure we add the UNID
this.put("unid", doc.getUniversalID());
} catch (Exception e) {
logger.log(Level.SEVERE,null, e);
}
}
示例9: removeAll
import lotus.domino.Document; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void removeAll(Document doc) throws NotesException{
boolean save = false;
Vector<String> attachments = doc.getParentDatabase().getParent().evaluate("@AttachmentNames", doc);
for(String attach : attachments){
EmbeddedObject eo = doc.getAttachment(attach);
if(eo!=null && eo.getType() == EmbeddedObject.EMBED_ATTACHMENT){
eo.remove();
save = true;
}//end if
}//end for
//only save if we need to.
if(save) {
doc.save();
}
}
示例10: testShareWithDocumentMock
import lotus.domino.Document; //导入依赖的package包/类
@Test
public void testShareWithDocumentMock() {
Document docMock = EasyMockWrapper.createNiceMock(Document.class);
try {
expect(docMock.getItemValueString("ShareName")).andReturn("WebGate");
expect(docMock.getItemValueInteger("Count")).andReturn(5);
expect(docMock.getItemValueInteger("PricePerShare")).andReturn(2870);
replay(docMock);
Share shareWebGate = Share.initFromDocument(docMock);
assertEquals("WebGate", shareWebGate.getShareName());
assertEquals(5 * 2870, shareWebGate.getValue());
} catch (Exception e) {
e.printStackTrace();
assertFalse(true);
}
}
示例11: getDateField
import lotus.domino.Document; //导入依赖的package包/类
public static Calendar getDateField(Document doc, String fieldName) throws NotesException {
Calendar result=null;
Item someItem=null;
DateTime someDate=null;
try {
someItem=doc.getFirstItem(fieldName);
if(null != someItem && someItem.getType()==Item.DATETIMES) {
someDate=someItem.getDateTimeValue();
result=Calendar.getInstance();
result.setTime(someDate.toJavaDate());
}
return result;
} catch(NotesException ne) {
throw ne;
} finally {
recycleObjects(someItem, someDate);
}
}
示例12: 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) { }
}
}
示例13: getDocument
import lotus.domino.Document; //导入依赖的package包/类
public static Document getDocument(Object var) {
if (var instanceof Document) {
return (Document) var;
}
if (var instanceof DominoDocument) {
return ((DominoDocument) var).getDocument();
}
if (var instanceof String) {
Object data = FacesUtil.resolveRequestMapVariable(FacesContext.getCurrentInstance(), (String) var);
if (data instanceof DominoDocument) {
DominoDocument dd = (DominoDocument) data;
return (Document) dd.getDocument();
}
if (data instanceof Document) {
return (Document) data;
}
}
throw new FacesExceptionEx(null, "Cannot find document {0}", var); // $NLX-NotesFunctionEx_CannotFindNotesDocument-1$
}
示例14: evaluate
import lotus.domino.Document; //导入依赖的package包/类
public Object evaluate(RestDocumentService service, Document document) throws ServiceException {
// TODO: How can we cache the item name so we do not reevaluate it all the time?
String itemName = getItemName();
try {
if(StringUtil.isNotEmpty(itemName) && document.hasItem(itemName)) {
return document.getItemValue(itemName);
}
} catch (NotesException e) {
throw new ServiceException(e);
}
String var = service.getParameters().getVar();
if(StringUtil.isNotEmpty(var)) {
// TODO: Do that on a per item basis only...
Object old = service.getHttpRequest().getAttribute(var);
try {
service.getHttpRequest().setAttribute(var,document);
return getValue();
} finally {
service.getHttpRequest().setAttribute(var,old);
}
} else {
return getValue();
}
}
示例15: getEventCode
import lotus.domino.Document; //导入依赖的package包/类
/**
* This example uses DocumentUniqueId as the event code.
*
* @return the event code we will use for Participant docs
*/
private String getEventCode() {
if(StringUtil.isEmpty(eventCode)) {
Document eventDoc=getDoc();
try {
eventCode = eventDoc.getUniversalID();
} catch (NotesException e) {
// Use OpenNTF Domino API to get rid of this.
e.printStackTrace();
}
}
return eventCode;
}