本文整理汇总了Java中lotus.domino.RichTextItem类的典型用法代码示例。如果您正苦于以下问题:Java RichTextItem类的具体用法?Java RichTextItem怎么用?Java RichTextItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RichTextItem类属于lotus.domino包,在下文中一共展示了RichTextItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanForAttachedJson
import lotus.domino.RichTextItem; //导入依赖的package包/类
/**
* Scan for attached json.
*
* @param rtitem the rtitem
* @return the string
* @throws NotesException the notes exception
*/
private String scanForAttachedJson(RichTextItem rtitem)throws NotesException{
String json = null;
@SuppressWarnings("unchecked")
Vector<EmbeddedObject> objects = rtitem.getEmbeddedObjects();
for(EmbeddedObject eo: objects){
if(eo.getName().toLowerCase().endsWith(StringCache.DOT_JSON)){
InputStream in = eo.getInputStream();
try {
json = IOUtils.toString(in,StringCache.UTF8);
int start = json.indexOf(StringCache.OPEN_CURLY_BRACE);
int end = json.lastIndexOf(StringCache.CLOSE_CURLY_BRACE);
json=json.substring(start,end) + StringCache.CLOSE_CURLY_BRACE;
} catch (IOException e) {
LOG.log(Level.SEVERE,null,e);
}finally{
IOUtils.closeQuietly(in);
eo.recycle();
eo = null;
}
}
}
return json;
}
示例2: attach
import lotus.domino.RichTextItem; //导入依赖的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();
}
}
}
示例3: publish
import lotus.domino.RichTextItem; //导入依赖的package包/类
@Override
public void publish(LogRecord logEvent) {
if (m_Level.intValue() > logEvent.getLevel().intValue()) {
return;
}
try {
Session sesCurrent = ExtLibUtil.getCurrentSessionAsSigner();
Database ndbCurrent = sesCurrent.getCurrentDatabase();
Document docLog = ndbCurrent.createDocument();
docLog.replaceItemValue("form", "frmLog");
docLog.replaceItemValue("sevn", logEvent.getLevel().intValue());
docLog.replaceItemValue("SRCNAME", m_CallerClass);
docLog.replaceItemValue("ERRORMSG", logEvent.getMessage());
if (logEvent.getThrown() != null) {
Throwable trCurrent = logEvent.getThrown();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
trCurrent.printStackTrace(pw);
RichTextItem rtCurrent = docLog.createRichTextItem("BodyRT");
rtCurrent.appendText(sw.toString());
}
docLog.save(true, false, true);
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: writeException
import lotus.domino.RichTextItem; //导入依赖的package包/类
private void writeException(Exception exCurrent, Document docJob) {
Document docEx;
try {
docEx = docJob.getParentDatabase().createDocument();
docEx.replaceItemValue("form", "frmException");
docEx.replaceItemValue("MessageT", exCurrent.getMessage());
docEx.replaceItemValue("JobIDT", m_JobID);
if (exCurrent instanceof SQLConnectorException) {
docEx.replaceItemValue("EventIDN",
((SQLConnectorException) exCurrent).getEventNr());
}
docEx.makeResponse(docJob);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exCurrent.printStackTrace(pw);
RichTextItem rtCurrent = docEx.createRichTextItem("BodyRT");
rtCurrent.appendText(sw.toString());
docEx.save(true, false, true);
} catch (NotesException e) {
e.printStackTrace();
}
}
示例5: attach
import lotus.domino.RichTextItem; //导入依赖的package包/类
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){
logger.log(Level.SEVERE,null,e);
}finally{
if(file!=null && file.exists()){
file.delete();
}
}
}
示例6: scanForAttachedJson
import lotus.domino.RichTextItem; //导入依赖的package包/类
private String scanForAttachedJson(RichTextItem rtitem)throws NotesException{
String json = null;
@SuppressWarnings("unchecked")
Vector<EmbeddedObject> objects = rtitem.getEmbeddedObjects();
for(EmbeddedObject eo: objects){
if(eo.getName().toLowerCase().endsWith(".json")){
InputStream in = eo.getInputStream();
try {
json = IOUtils.toString(in,"UTF-8");
int start = json.indexOf('{');
int end = json.lastIndexOf('}');
json=json.substring(start,end) + "}";
} catch (IOException e) {
logger.log(Level.SEVERE,null,e);
}finally{
IOUtils.closeQuietly(in);
eo.recycle();
eo = null;
}
}
}
return json;
}
示例7: buildDocument
import lotus.domino.RichTextItem; //导入依赖的package包/类
public Document buildDocument(HttpServletRequest req, Database db, File file) throws NotesException{
Document doc = db.createDocument();
int lastSlash = req.getContextPath().lastIndexOf("/");
String type = req.getContextPath().substring(lastSlash,req.getContextPath().length());
doc.replaceItemValue("type", type);
doc.replaceItemValue("Form", "fmUpload");
doc.replaceItemValue("author", ContextInfo.getUserSession().getEffectiveUserName());
doc.replaceItemValue("contextPath", req.getContextPath());
doc.replaceItemValue("author", db.getParent().getEffectiveUserName());
RichTextItem rtitem = doc.createRichTextItem(WebshellConstants.FIELD_ATTACHMENTS);
rtitem.embedObject(EmbeddedObject.EMBED_ATTACHMENT,null, file.getAbsolutePath(), file.getName());
return doc;
}
示例8: buildMessage
import lotus.domino.RichTextItem; //导入依赖的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;
}
示例9: onOpenOrClose
import lotus.domino.RichTextItem; //导入依赖的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);
}
}
示例10: onMessage
import lotus.domino.RichTextItem; //导入依赖的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);
}
}
示例11: attach
import lotus.domino.RichTextItem; //导入依赖的package包/类
public static void attach(File file, Document doc, String field) throws IOException, NotesException{
RichTextItem item = getRichText(doc, field);
item.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, file.getAbsolutePath(), file.getName());
doc.save();
item.recycle();
file.delete();
}
示例12: removeFile
import lotus.domino.RichTextItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void removeFile(FileHelper fh) {
try {
Database ndbCurrent = ExtLibUtil.getCurrentSession().getDatabase(
fh.getServer(), fh.getPath());
if (ndbCurrent == null)
return;
Document docCurrent = ndbCurrent.getDocumentByUNID(fh.getDocID());
if (docCurrent == null){
ndbCurrent.recycle();
return;
}
// RESULTS IN NOTE ITEM NOT FOUND ERROR AFTERWARDS
// EmbeddedObject entity = docCurrent.getAttachment(fh.getName());
// if (entity == null)
// return;
// entity.remove();
RichTextItem rti = (RichTextItem) docCurrent.getFirstItem(fh
.getFieldName());
Vector<EmbeddedObject> entitys = rti.getEmbeddedObjects();
for (EmbeddedObject entity : entitys) {
if (entity.getType() == EmbeddedObject.EMBED_ATTACHMENT) {
if (entity.getName().equals(fh.getName())) {
entity.remove();
break;
}
}
}
docCurrent.save(true, false, true);
rti.recycle();
docCurrent.recycle();
ndbCurrent.recycle();
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: sendLink
import lotus.domino.RichTextItem; //导入依赖的package包/类
public static boolean sendLink(String strURL, String strID, List<String> sendTo, String strComment, Session sesCurrent) {
try {
Document docMail = sesCurrent.getCurrentDatabase().createDocument();
docMail.replaceItemValue("SendTo", sendTo);
docMail.replaceItemValue("Subject", sesCurrent.getCurrentDatabase().getTitle() + ": please check this link");
RichTextItem rtiBody = docMail.createRichTextItem("Body");
IScrumDocument doc = ScrumDocumentSessionFacade.get().getDocumentById(strID);
if (doc != null) {
rtiBody.appendText("Project: " + doc.getProject());
rtiBody.addNewLine(1);
rtiBody.appendText("Type: " + doc.getForm());
rtiBody.addNewLine(1);
rtiBody.appendText("Subject: " + doc.getSubject());
rtiBody.addNewLine(2);
}
rtiBody.appendText("" + strURL);
rtiBody.addNewLine(2);
rtiBody.appendText(strComment);
docMail.send(false);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
示例14: reportMsg
import lotus.domino.RichTextItem; //导入依赖的package包/类
private void reportMsg(SimpleDateFormat sdfCurrent, RichTextItem rtReport,
String strMsg) {
try {
rtReport.appendText(sdfCurrent.format(new Date()) + " " + strMsg);
rtReport.addNewLine();
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例15: buildDocument
import lotus.domino.RichTextItem; //导入依赖的package包/类
@Override
public Document buildDocument(Database db, File file, String form, String attachmentField) throws NotesException {
Document doc = db.createDocument();
doc.replaceItemValue("Form", form);
doc.replaceItemValue("author", ContextInfo.getUserSession().getEffectiveUserName());
RichTextItem rtitem = doc.createRichTextItem(attachmentField);
rtitem.embedObject(EmbeddedObject.EMBED_ATTACHMENT,null, file.getAbsolutePath(), file.getName());
doc.save();
return doc;
}