本文整理汇总了Java中lotus.domino.MIMEEntity类的典型用法代码示例。如果您正苦于以下问题:Java MIMEEntity类的具体用法?Java MIMEEntity怎么用?Java MIMEEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MIMEEntity类属于lotus.domino包,在下文中一共展示了MIMEEntity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: writeMimeEntity
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private void writeMimeEntity(Writer writer, MIMEEntity mimeEntity)
throws NotesException, IOException {
String headers;
String content;
int encoding;
headers = mimeEntity.getHeaders();
encoding = mimeEntity.getEncoding();
if (encoding == MIMEEntity.ENC_IDENTITY_BINARY) {
mimeEntity.encodeContent(MIMEEntity.ENC_BASE64);
headers = mimeEntity.getHeaders();
}
content = mimeEntity.getBoundaryStart();
writer.write(content);
if (!content.endsWith("\n")) //$NON-NLS-1$
writer.write("\n"); //$NON-NLS-1$
// TODO: Is there a better way to output the headers?
writer.write(headers);
writer.write("\n\n"); //$NON-NLS-1$
content = mimeEntity.getContentAsText();
if (content != null && content.length() > 0)
writer.write(content);
writer.write(mimeEntity.getBoundaryEnd());
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:26,代码来源:MimeMessageGenerator.java
示例2: addEntityAdapter
import lotus.domino.MIMEEntity; //导入依赖的package包/类
/**
* Recursively adds entity adapters to a flat list (depth first)
*
* @param adapters
* @param entity
* @throws NotesException
*/
public static void addEntityAdapter(List<JsonMimeEntityAdapter> adapters, MIMEEntity entity) throws NotesException {
// Add this entity
JsonMimeEntityAdapter adapter = new JsonMimeEntityAdapter(entity);
adapters.add(adapter);
// Add children
MIMEEntity child = entity.getFirstChildEntity();
if ( child != null ) {
addEntityAdapter(adapters, child);
// Add siblings
MIMEEntity sibling = child.getNextSibling();
while ( sibling != null ) {
addEntityAdapter(adapters, sibling);
sibling = sibling.getNextSibling();
}
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:30,代码来源:JsonMimeEntityAdapter.java
示例3: processJava2Domino
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public void processJava2Domino(Document docCurrent, Object objCurrent, String strNotesField, String strJavaField, HashMap<String, Object> addValues) {
try {
MimeMultipart body = getValue(objCurrent, strJavaField);
Stream stream = docCurrent.getParentDatabase().getParent().createStream();
if (body != null)
stream.writeText(body.getHTML());
else
return;
MIMEEntity entity = docCurrent.getMIMEEntity(strNotesField);
if (entity == null) {
docCurrent.removeItem(strNotesField);
entity = docCurrent.createMIMEEntity(strNotesField);
}
entity.setContentFromText(stream, "text/html;charset=UTF-8", 1725);
stream.close();
// docCurrent.replaceItemValue(strNotesField, strValue);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:OpenNTF,项目名称:myWebGate-Scrum,代码行数:26,代码来源:MimeMultipartBinder.java
示例4: processDomino2Java
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public void processDomino2Java(Document docCurrent, Object objCurrent,
String strNotesField, String strJavaField,
HashMap<String, Object> addValues) {
try {
MimeMultipart strValue = null;
Method mt = objCurrent.getClass().getMethod("set" + strJavaField,
MimeMultipart.class);
MIMEEntity entity = docCurrent.getMIMEEntity(strNotesField);
if (entity != null) {
strValue = MimeMultipart.fromHTML(entity.getContentAsText());
}
mt.invoke(objCurrent, strValue);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:OpenNTF,项目名称:Nagios4DominoIntegration,代码行数:18,代码来源:MimeMultipartBinder.java
示例5: processJava2Domino
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public void processJava2Domino(Document docCurrent, Object objCurrent,
String strNotesField, String strJavaField,
HashMap<String, Object> addValues) {
try {
MimeMultipart body = getValue(objCurrent, strJavaField);
Stream stream = docCurrent.getParentDatabase().getParent().createStream();
stream.writeText(body.getHTML());
MIMEEntity entity = docCurrent.getMIMEEntity(strNotesField);
if(entity == null)
entity = docCurrent.createMIMEEntity(strNotesField);
entity.setContentFromText(stream,"text/html;charset=UTF-8", 1725);
stream.close();
//docCurrent.replaceItemValue(strNotesField, strValue);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:OpenNTF,项目名称:Nagios4DominoIntegration,代码行数:24,代码来源:MimeMultipartBinder.java
示例6: extractMimeText
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private String extractMimeText(MIMEEntity entity, String mimeType, Session sesCurrent) throws NotesException {
String content = null;
MIMEHeader mimeContentType = entity.getNthHeader("Content-Type");
MIMEHeader mimeDispostion = entity.getNthHeader("Content-Disposition");
if ((mimeContentType != null) && (mimeDispostion == null)) {
String headerValue = mimeContentType.getHeaderVal();
if (headerValue.startsWith("multipart")) {
MIMEEntity childNext = entity.getFirstChildEntity();
while ((childNext != null) && (content == null)) {
MIMEEntity child = childNext;
childNext = child.getNextSibling();
content = extractMimeText(child, mimeType, sesCurrent);
child.recycle();
}
} else if ((mimeType != null) && (headerValue.startsWith(mimeType))) {
content = getContentsAsText(entity, sesCurrent);
}
mimeContentType.recycle();
} else if ((mimeType == null) && (mimeDispostion == null)) {
content = getContentsAsText(entity, sesCurrent);
}
return content;
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:25,代码来源:MimeMultipartBinder.java
示例7: writeItemAsMime
import lotus.domino.MIMEEntity; //导入依赖的package包/类
protected void writeItemAsMime(JsonWriter jsonWriter, Item item, String propName) throws IOException, NotesException, ServiceException {
MimeEntityHelper helper = null;
String itemName = item.getName();
jsonWriter.startProperty(propName);
jsonWriter.startObject();
writeProperty(jsonWriter, ATTR_TYPE, TYPE_MULTIPART);
jsonWriter.startProperty(ATTR_CONTENT);
try {
List<JsonMimeEntityAdapter> adapters = new ArrayList<JsonMimeEntityAdapter>();
helper = new MimeEntityHelper(document, itemName);
MIMEEntity entity = helper.getFirstMimeEntity(true);
if ( entity != null ) {
JsonMimeEntityAdapter.addEntityAdapter(adapters, entity);
}
jsonWriter.outLiteral(adapters);
}
catch (JsonException e) {
throw new ServiceException(e);
}
finally {
if ( helper != null ) {
helper.recycle();
}
jsonWriter.endProperty();
jsonWriter.endObject();
jsonWriter.endProperty();
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:29,代码来源:JsonDocumentContent.java
示例8: updateMimePart
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private void updateMimePart(String itemName, JsonJavaObject jsonObject) throws NotesException, JsonException {
if ( document.hasItem(itemName) ) {
Item item = document.getFirstItem(itemName);
if ( item.getType() == Item.MIME_PART ) {
// SPR #JJVX8RGJZG: When updating _existing_ MIME parts, we were
// leaving old attachments around. The fix is to explicitly remove
// the parts first.
MIMEEntity entity = item.getMIMEEntity();
entity.remove();
document.closeMIMEEntities(true, itemName);
}
}
Object jsonMime = jsonObject.get(ATTR_CONTENT);
List<JsonJavaObject> parts = (List<JsonJavaObject>)jsonMime;
ParserContext context = new ParserContext(document, itemName);
for ( int i = 0; i < parts.size(); i++ ) {
JsonJavaObject obj = parts.get(i);
boolean lastEntity = false;
if ( (i+1) == parts.size() ) {
lastEntity = true;
}
JsonMimeEntityAdapter adapter = new JsonMimeEntityAdapter(context, obj);
context.setCurrentEntityAdapter(adapter);
adapter.flushJsonProperties(lastEntity);
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:32,代码来源:JsonDocumentContent.java
示例9: getNotesHeader
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private static MIMEHeader getNotesHeader(MIMEEntity entity, String headerName) throws NotesException {
MIMEHeader header = null;
Vector<MIMEHeader> headers = entity.getHeaderObjects();
for ( MIMEHeader thisHeader : headers ) {
if ( thisHeader.getHeaderName().equalsIgnoreCase(headerName) ) {
header = thisHeader;
break;
}
}
return header;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:12,代码来源:MimeMessageParser.java
示例10: addEntity
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public void addEntity(String key, MIMEEntity entity) {
_entityMap.put(key, entity);
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:4,代码来源:JsonMimeEntityAdapter.java
示例11: addHeader
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private void addHeader(String property, String header, MIMEEntity entity) throws NotesException {
String value = (String)_objectCache.getJsonProperty(property);
if (!StringUtil.isEmpty(value)) {
MIMEHeader mimeHeader = entity.createHeader(header);
mimeHeader.setHeaderVal(value);
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:8,代码来源:JsonMimeEntityAdapter.java
示例12: saveState
import lotus.domino.MIMEEntity; //导入依赖的package包/类
/**
* Save state. Imported from org.openntf.domino
*
* @param object
* the object
* @param doc
* the doc
* @param itemName
* the item name
* @param compress
* the compress
* @throws Throwable
* the throwable
*/
public static void saveState(Serializable object, Document doc, String itemName, boolean compress, Map<String, String> headers) throws Throwable {
Session session=doc.getParentDatabase().getParent();
boolean convertMime = session.isConvertMime();
session.setConvertMime(false);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream objectStream = compress ? new ObjectOutputStream(new GZIPOutputStream(byteStream)) : new ObjectOutputStream(
byteStream);
String contentType = null;
// Prefer externalization if available
if(object instanceof Externalizable) {
((Externalizable)object).writeExternal(objectStream);
contentType = "application/x-java-externalized-object";
} else {
objectStream.writeObject(object);
contentType = "application/x-java-serialized-object";
}
objectStream.flush();
objectStream.close();
Stream mimeStream = session.createStream();
MIMEEntity previousState = doc.getMIMEEntity(itemName);
MIMEEntity entity = previousState == null ? doc.createMIMEEntity(itemName) : previousState;
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteStream.toByteArray());
mimeStream.setContents(byteIn);
entity.setContentFromBytes(mimeStream, contentType, MIMEEntity.ENC_NONE);
MIMEHeader contentEncoding = entity.getNthHeader("Content-Encoding");
if (compress) {
if (contentEncoding == null) {
contentEncoding = entity.createHeader("Content-Encoding");
}
contentEncoding.setHeaderVal("gzip");
contentEncoding.recycle();
} else {
if (contentEncoding != null) {
contentEncoding.remove();
contentEncoding.recycle();
}
}
MIMEHeader javaClass = entity.getNthHeader("X-Java-Class");
if (javaClass == null) {
javaClass = entity.createHeader("X-Java-Class");
}
javaClass.setHeaderVal(object.getClass().getName());
javaClass.recycle();
if(headers != null) {
for(Map.Entry<String, String> entry : headers.entrySet()) {
MIMEHeader paramHeader = entity.getNthHeader(entry.getKey());
if(paramHeader == null) {
paramHeader = entity.createHeader(entry.getKey());
}
paramHeader.setHeaderVal(entry.getValue());
paramHeader.recycle();
}
}
entity.recycle();
mimeStream.recycle();
session.setConvertMime(convertMime);
}
开发者ID:sbasegmez,项目名称:Blogged,代码行数:79,代码来源:DevelopiUtils.java
示例13: processJava2Domino
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public MimeMultipart[] processJava2Domino(Document docCurrent, Object objCurrent, Definition def) {
MimeMultipart[] mpRC = new MimeMultipart[2];
Logger log = LoggerFactory.getLogger(this.getClass().getCanonicalName());
try {
MimeMultipart oldBody = getRawValueFromStore(docCurrent, def.getNotesField());
MimeMultipart body = getValue(objCurrent, def.getJavaField());
mpRC[0] = oldBody;
mpRC[1] = body;
log.fine("oldBody = " + oldBody);
log.fine("body = " + body);
Stream stream = docCurrent.getParentDatabase().getParent().createStream();
if (body != null)
stream.writeText(body.getHTML());
else
return null;
MIMEEntity entity = docCurrent.getMIMEEntity(def.getNotesField());
log.info("entity = " + entity);
if (entity == null) {
docCurrent.removeItem(def.getNotesField());
log.info("creating Entity for " + def.getNotesField());
entity = docCurrent.createMIMEEntity(def.getNotesField());
log.info("new entity created");
}
stream.setPosition(0);
entity.setContentFromText(stream, "text/html;charset=UTF-8", 1725);
stream.close();
log.info("done");
} catch (Exception e) {
LoggerFactory.logWarning(this.getClass(), "Error during processJava2Domino", e);
throw new XPTRuntimeException("Error during processJava2Domino", e);
}
return mpRC;
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:38,代码来源:MimeMultipartBinder.java
示例14: getContentFromMime
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private String getContentFromMime(MIMEEntity entity, Session parent) throws NotesException {
String content;
content = extractMimeText(entity, "text/html", parent);
if (content == null) {
content = extractMimeText(entity, "text/plain", parent);
content = HtmlUtil.toHTMLContentString(content, true, HtmlUtil.useHTML);
}
if (content == null) {
content = extractMimeText(entity, null, parent);
}
return content;
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:13,代码来源:MimeMultipartBinder.java
示例15: getContentsAsText
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private String getContentsAsText(MIMEEntity child, Session sesCurrent) throws NotesException {
Stream stream = sesCurrent.createStream();
child.getContentAsText(stream, true);
stream.setPosition(0);
String str = stream.readText();
stream.recycle();
return str;
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:9,代码来源:MimeMultipartBinder.java
示例16: writeMimeOutput
import lotus.domino.MIMEEntity; //导入依赖的package包/类
private void writeMimeOutput(Document document, String itemName, Writer writer)
throws NotesException, IOException {
MIMEEntity mimeEntity = null;
MIMEEntity mChild = null;
String contenttype = null;
String headers = null;
MimeEntityHelper helper = null;
if (!document.hasItem(itemName)) {
// SPR# WJBJ9PE86G: The body item doesn't exist, so create one now
mimeEntity = document.createMIMEEntity(itemName);
}
else {
helper = new MimeEntityHelper(document, itemName);
mimeEntity = helper.getFirstMimeEntity();
if (mimeEntity == null) {
throw new NullPointerException("Invalid item."); // $NLX-MimeMessageGenerator_InvalidItem-1$
}
}
try {
contenttype = mimeEntity.getContentType();
headers = mimeEntity.getHeaders();
// TODO: Is there a better way to output the headers?
if (!headers.startsWith("MIME-Version:")) { //$NON-NLS-1$
writer.write("MIME-Version: 1.0"); //$NON-NLS-1$
}
// Write MIMEEntity.
writeMimeEntity(writer, mimeEntity);
if (contenttype.startsWith(MULTIPART)) {
mChild = mimeEntity.getFirstChildEntity();
while (mChild != null) {
// Write MIMEEntity.
writeMimeEntity(writer, mChild);
MIMEEntity mChild2 = mChild.getFirstChildEntity();
if (mChild2 == null) {
mChild2 = mChild.getNextSibling();
if (mChild2 == null) {
mChild2 = mChild.getParentEntity();
if (mChild2 != null)
mChild2 = mChild2.getNextSibling();
}
}
mChild.recycle();
mChild = mChild2;
}
}
writer.write(mimeEntity.getBoundaryEnd());
} finally {
if (helper != null) {
helper.recycle();
}
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:56,代码来源:MimeMessageGenerator.java
示例17: getFirstMimeEntity
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public MIMEEntity getFirstMimeEntity(boolean ignoreForm) throws NotesException {
if ( _mimeEntity == null ) {
Database database = _document.getParentDatabase();
Session session = database.getParent();
boolean restoreConvertMime = false;
if (session.isConvertMime()) {
// Do not convert MIME to rich text.
session.setConvertMIME(false);
restoreConvertMime = true;
}
try {
Item item = _document.getFirstItem(_itemName);
if (item != null) {
if (item.getType() == Item.RICHTEXT) {
if ( ITEM_BODY.equalsIgnoreCase(_itemName) && !ignoreForm) {
_document.removeItem("$KeepPrivate"); //$NON-NLS-1$
_document.convertToMIME(lotus.domino.Document.CVT_RT_TO_PLAINTEXT_AND_HTML, 0);
_mimeEntity = _document.getMIMEEntity(_itemName);
}
else {
_tempDocument = database.createDocument();
_tempDocument.copyItem(item, ITEM_BODY);
_tempDocument.convertToMIME(lotus.domino.Document.CVT_RT_TO_PLAINTEXT_AND_HTML, 0);
_mimeEntity = _tempDocument.getMIMEEntity(ITEM_BODY);
}
}
else if (item.getType() == Item.MIME_PART) {
_mimeEntity = _document.getMIMEEntity(_itemName);
}
}
}
finally {
if (restoreConvertMime) {
session.setConvertMime(true);
}
}
}
return _mimeEntity;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:45,代码来源:MimeEntityHelper.java
示例18: getRootEntity
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public MIMEEntity getRootEntity() {
return _rootEntity;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:4,代码来源:JsonMimeEntityAdapter.java
示例19: setRootEntity
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public void setRootEntity(MIMEEntity rootEntity) {
_rootEntity = rootEntity;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:4,代码来源:JsonMimeEntityAdapter.java
示例20: getEntity
import lotus.domino.MIMEEntity; //导入依赖的package包/类
public MIMEEntity getEntity(String key) {
return _entityMap.get(key);
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:4,代码来源:JsonMimeEntityAdapter.java
注:本文中的lotus.domino.MIMEEntity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论