• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java MIMEHeader类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中lotus.domino.MIMEHeader的典型用法代码示例。如果您正苦于以下问题:Java MIMEHeader类的具体用法?Java MIMEHeader怎么用?Java MIMEHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

MIMEHeader类属于lotus.domino包,在下文中一共展示了MIMEHeader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: extractMimeText

点赞 3

import lotus.domino.MIMEHeader; //导入依赖的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

示例2: getNotesHeader

点赞 2

import lotus.domino.MIMEHeader; //导入依赖的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

示例3: addHeader

点赞 2

import lotus.domino.MIMEHeader; //导入依赖的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

示例4: saveState

点赞 2

import lotus.domino.MIMEHeader; //导入依赖的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

示例5: getJsonProperty

点赞 2

import lotus.domino.MIMEHeader; //导入依赖的package包/类
public Object getJsonProperty(String property) {
	
	Object value = null;

	try {
		MIMEHeader header = null;
		
		if ( CONTENT_TYPE_PROP.equals(property) ) {
			header = _entity.getNthHeader(CONTENT_TYPE_HEADER);
		}
		else if ( CONTENT_ID_PROP.equals(property) ) {
			header = _entity.getNthHeader(CONTENT_ID_HEADER);
		}
		else if ( CONTENT_DISPOSITION_PROP.equals(property) ) {
			header = _entity.getNthHeader(CONTENT_DISPOSITION_HEADER);
		}
		else if ( CONTENT_TRANSFER_ENCODING_PROP.equals(property) ) {
			header = _entity.getNthHeader(CONTENT_TRANSFER_ENCODING_HEADER);
		}
		
		if ( header != null ) {
			value = header.getHeaderValAndParams().trim();
		}
		else if ( DATA_PROP.equals(property) ) {
	        String content = _entity.getContentAsText();
			header = _entity.getNthHeader(CONTENT_TYPE_HEADER);
			if ( header != null && header.getHeaderVal().toLowerCase().contains(MULTIPART) ) {
				value = content.trim();
			} 
	        else {
	        	value = content;
	        }
		}
		else if ( BOUNDARY_PROP.equals(property) ) {
            String boundaryStart = _entity.getBoundaryStart();
            value = boundaryStart.trim();
		}
		
		if ( value == null ) {
			value = "null"; //$NON-NLS-1$
		}
	}
	catch (NotesException e) {
           Logger.get().warnp(this, "getJsonProperty",//$NON-NLS-1$
                   e, "Unhandled exception getting a JSON property value");// $NLW-JsonMimeEntityAdapter_UnhandledExceptionInGetJsonProperty-1$
	}
	
	return value;
}
 

开发者ID:OpenNTF,
项目名称:XPagesExtensionLibrary,
代码行数:50,
代码来源:JsonMimeEntityAdapter.java

示例6: sendAssigneeEmail

点赞 2

import lotus.domino.MIMEHeader; //导入依赖的package包/类
public static void sendAssigneeEmail(String email, String ticketLink, String eeUrl) {
	Session session = ExtLibUtil.getCurrentSession(FacesContext.getCurrentInstance());
	lotus.domino.DbDirectory dir = null;
	Database mail = null;
	Document doc = null;
	MIMEEntity mime = null;
	lotus.domino.Stream stream = null;
	try {
		dir = session.getDbDirectory("");
		mail = dir.openMailDatabase();
		doc = mail.createDocument();
		doc.appendItemValue("Form", "Memo");
		doc.appendItemValue("Subject", "A New Trouble Ticket Has Been Assigned To You");
		doc.appendItemValue("SendTo", email);
		
		boolean convertMime = session.isConvertMime();
		session.setConvertMIME(false);

		MIMEEntity topMime = doc.createMIMEEntity("Body");

		// Set up the multipart header
		MIMEHeader header = topMime.createHeader("Content-Type");

		// EE needs to use multipart/alternative or the email clients will turn the
		// content into an attachment.
		header.setHeaderVal("multipart/alternative");
		header = topMime.createHeader("MIME-Version");
		header.setHeaderVal("1.0");
		header = topMime.createHeader("Content-transfer-encoding");
		header.setHeaderVal("7bit");
		
		mime = topMime.createChildEntity();
		stream = session.createStream();
		stream.writeText("A new trouble ticket was assigned to you. " + ticketLink);
		mime.setContentFromText(stream, "text/plain", MIMEEntity.ENC_IDENTITY_7BIT);
		stream.close();
		stream.recycle();
		mime.recycle();
		
		mime = topMime.createChildEntity();
		stream = session.createStream();
		stream.writeText("A new <a href=\"" + ticketLink + "\">trouble ticket</a> was assigned to you.");
		mime.setContentFromText(stream, "text/html", MIMEEntity.ENC_IDENTITY_7BIT);
		stream.close();
		stream.recycle();
		mime.recycle();
		
		mime = topMime.createChildEntity();
		stream = session.createStream();
		stream.writeText("{\"url\":\"" + eeUrl + "\"}");
		mime.setContentFromText(stream, "application/embed+json", MIMEEntity.ENC_IDENTITY_7BIT);
		stream.close();
		stream.recycle();
		mime.recycle();
		
		doc.save();
		doc.send();
		
		// Set mime conversion back to what it was originally
		session.setConvertMIME(convertMime);

	} catch (NotesException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} finally {
		recycle(dir);
		recycle(mail);
		recycle(doc);
	}
}
 

开发者ID:OpenNTF,
项目名称:TroubleTickets,
代码行数:71,
代码来源:XPagesTickets.java

示例7: processJava2Domino

点赞 2

import lotus.domino.MIMEHeader; //导入依赖的package包/类
public Object[] processJava2Domino(Document docCurrent, Object objCurrent, Definition def) {
	Object[] objRC = new Object[2];
	try {
		Object oldBody = getRawValueFromStore(docCurrent, def.getNotesField());
		Object body = getValue(objCurrent, def.getJavaField());
		objRC[0] = oldBody;
		objRC[1] = body;
		Session session = docCurrent.getParentDatabase().getParent();

		boolean convertMime = session.isConvertMime();
		session.setConvertMime(false);

		ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
		ObjectOutputStream objectStream = new ObjectOutputStream(new GZIPOutputStream(byteStream));
		objectStream.writeObject(body);
		objectStream.flush();
		objectStream.close();

		MIMEEntity entity = null;
		MIMEEntity previousState = docCurrent.getMIMEEntity(def.getNotesField());
		if (previousState == null) {
			entity = docCurrent.createMIMEEntity(def.getNotesField());
		} else {
			entity = previousState;
		}
		Stream mimeStream = session.createStream();
		ByteArrayInputStream byteIn = new ByteArrayInputStream(byteStream.toByteArray());
		mimeStream.setContents(byteIn);
		entity.setContentFromBytes(mimeStream, "application/x-java-serialized-object", MIMEEntity.ENC_NONE);

		MIMEHeader header = entity.getNthHeader("Content-Encoding");
		if (header == null) {
			header = entity.createHeader("Content-Encoding");
		}
		header.setHeaderVal("gzip");

		header.recycle();
		entity.recycle();
		mimeStream.recycle();

		session.setConvertMime(convertMime);

	} catch (Exception e) {
		LoggerFactory.logWarning(getClass(), "Error during processJava2Domino", e);
	}
	return objRC;

}
 

开发者ID:OpenNTF,
项目名称:XPagesToolkit,
代码行数:49,
代码来源:ObjectBinder.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)