本文整理汇总了Java中lotus.domino.EmbeddedObject类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedObject类的具体用法?Java EmbeddedObject怎么用?Java EmbeddedObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedObject类属于lotus.domino包,在下文中一共展示了EmbeddedObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanForAttachedJson
import lotus.domino.EmbeddedObject; //导入依赖的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.EmbeddedObject; //导入依赖的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: removeAll
import lotus.domino.EmbeddedObject; //导入依赖的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();
}
}
示例4: attach
import lotus.domino.EmbeddedObject; //导入依赖的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();
}
}
}
示例5: scanForAttachedJson
import lotus.domino.EmbeddedObject; //导入依赖的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;
}
示例6: buildDocument
import lotus.domino.EmbeddedObject; //导入依赖的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;
}
示例7: remove
import lotus.domino.EmbeddedObject; //导入依赖的package包/类
public static void remove(Document doc, String attachmentName) throws NotesException{
EmbeddedObject eo = doc.getAttachment(attachmentName);
if(eo!=null){
eo.remove();
doc.save();
}
}
示例8: attach
import lotus.domino.EmbeddedObject; //导入依赖的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();
}
示例9: getFileSteam
import lotus.domino.EmbeddedObject; //导入依赖的package包/类
public InputStream getFileSteam(FileHelper fh) {
try {
Database ndbCurrent = ExtLibUtil.getCurrentSession().getDatabase(
fh.getServer(), fh.getPath());
if (ndbCurrent == null)
return null;
Document docCurrent = ndbCurrent.getDocumentByUNID(fh.getDocID());
if (docCurrent == null){
ndbCurrent.recycle();
return null;
}
EmbeddedObject entity = docCurrent.getAttachment(fh.getName());
if (entity == null){
ndbCurrent.recycle();
docCurrent.recycle();
return null;
}
InputStream is = entity.getInputStream();
entity.recycle();
docCurrent.recycle();
ndbCurrent.recycle();
return is;// entity.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例10: removeFile
import lotus.domino.EmbeddedObject; //导入依赖的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();
}
}
示例11: getStream
import lotus.domino.EmbeddedObject; //导入依赖的package包/类
/**
* @see biz.taoconsulting.dominodav.resource.DAVAbstractResource#getStream()
* Originally I tried EmbeddedObject.getInputStream(); but that didn't
* go down well with the servlet, so now I use a temp file approach
* where an attachment is stored into a temp file and then served to
* the servlet as fileinput stream
*/
public InputStream getStream() {
Session s = null;
InputStream curStream = null;
String notesURL = this.getInternalAddress();
Document curDoc = null;
s = DominoProxy.getUserSession();
if (s != null) {
try {
// We need to find the $File to isolate the document
int dollarFile = notesURL.lastIndexOf("/$File");
if (dollarFile < 0) {
// This is not an attachment
return null;
}
String docURL = notesURL.substring(0, dollarFile);
curDoc = (Document) s.resolve(docURL);
String curAttName = this.getName();
EmbeddedObject curAttachment = curDoc.getAttachment(curAttName);
File tempFile = this.getTempfile();
// Delete if it exists
if (tempFile.exists()) {
tempFile.delete();
}
curAttachment.extractFile(tempFile.getAbsolutePath());
curStream = new AttachmentInputStream(tempFile, this);
} catch (Exception e) {
LOGGER.error(e);
}
}
return curStream;
}
示例12: buildDocument
import lotus.domino.EmbeddedObject; //导入依赖的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;
}
示例13: getAttachmentResource
import lotus.domino.EmbeddedObject; //导入依赖的package包/类
/**
* Create a Attachment resource for an attachment inside of a document
*
* @param s
* @param curDoc
* @param curAttName
* @return
*/
private DAVResourceDominoAttachments getAttachmentResource(
boolean readOnly, Document curDoc, String curAttName) {
LOGGER.debug("Retrieving attachment [" + curAttName + "]");
EmbeddedObject curAttachment = null;
DAVResourceDominoAttachments curRes = null;
try {
curAttachment = curDoc.getAttachment(curAttName);
if (curAttachment == null) {
return null;
}
String docID = curDoc.getUniversalID();
Date curCreationDate = curDoc.getCreated().toJavaDate();
Date curChangeDate = curDoc.getLastModified().toJavaDate();
Long curSize = new Long(curAttachment.getFileSize());
String curName = curAttachment.getName();
String curInternalPath = docID + "/$File/"
+ curAttachment.getName();
// We hide the $File from external resources
String curExternalPath = docID + "/" + curAttachment.getName();
LOGGER.debug("Processing Attachment " + curName + " ("
+ curInternalPath + ")");
// Now the repository
String pubHRef = ((IDAVAddressInformation) this.getRepository())
.getPublicHref() + "/" + curExternalPath;
curRes = new DAVResourceDominoAttachments(this.getRepository());
curRes.setPublicHref(pubHRef);
curRes.setMember(true);
curRes.setName(curName);
curRes.setInternalAddress(((IDAVAddressInformation) this
.getRepository()).getInternalAddress()
+ "/"
+ curInternalPath);
curRes.setOwner(this.getRepository());
curRes.setResourceType("NotesAttachment");
curRes.setCreationDate(curCreationDate);
curRes.setLastModified(curChangeDate);
curRes.setContentLength(curSize);
curRes.setReadOnly(readOnly);
} catch (NotesException e) {
LOGGER.error(e);
}
return curRes;
}
示例14: getStream
import lotus.domino.EmbeddedObject; //导入依赖的package包/类
/**
* @see biz.taoconsulting.dominodav.resource.DAVAbstractResource#getStream()
* Originally I tried EmbeddedObject.getInputStream(); but that didn't
* go down well with the servlet, so now I use a temp file approach
* where an attachment is stored into a temp file and then served to
* the servlet as fileinput stream
*/
public InputStream getStream() {
Session s = null;
InputStream curStream = null;
String notesURL = this.getInternalAddress();
// LOGGER.info("NotesUrl="+notesURL);
Document curDoc = null;
s = DominoProxy.getUserSession();
if (s != null) {
try {
// We need to find the $File to isolate the document
int dollarFile = notesURL.lastIndexOf("/$File");
if (dollarFile < 0) {
// This is not an attachment
return null;
}
String docURL = notesURL.substring(0, dollarFile);
// LOGGER.info("docURL="+docURL);
curDoc = (Document) s.resolve(docURL);
String curAttName = this.getName();
curAttName = java.net.URLDecoder.decode(curAttName, "utf-8");
// LOGGER.info("curAttName="+curAttName);
EmbeddedObject curAttachment = curDoc.getAttachment(curAttName);
if (curAttachment == null) {
LOGGER.info("Attachment is null");
}
File tempFile = this.getTempfile();
// Delete if it exists
if (tempFile.exists()) {
tempFile.delete();
}
curAttachment.extractFile(tempFile.getAbsolutePath());
LOGGER.info("Current attachment path extracted is ="
+ tempFile.getAbsolutePath());
curStream = new DocumentInputStream(tempFile, this);
} catch (Exception e) {
LOGGER.error(e);
}
}
return curStream;
}
示例15: getStream
import lotus.domino.EmbeddedObject; //导入依赖的package包/类
/**
* @see biz.taoconsulting.dominodav.resource.DAVAbstractResource#getStream()
* Originally I tried EmbeddedObject.getInputStream(); but that didn't
* go down well with the servlet, so now I use a temp file approach
* where an attachment is stored into a temp file and then served to
* the servlet as fileinput stream
*/
public InputStream getStream() {
Session s = null;
InputStream curStream = null;
String notesURL = this.getInternalAddress();
// LOGGER.info("NotesUrl="+notesURL);
Document curDoc = null;
s = DominoProxy.getUserSession();
if (s != null) {
try {
// We need to find the $File to isolate the document
int dollarFile = notesURL.lastIndexOf("/$File");
if (dollarFile < 0) {
// This is not an attachment
return null;
}
String docURL = notesURL.substring(0, dollarFile);
LOGGER.info("docURL=" + docURL);
curDoc = (Document) s.resolve(docURL);
String curAttName = this.getName();
curAttName = java.net.URLDecoder.decode(curAttName, "utf-8");
LOGGER.info("curAttName=" + curAttName);
EmbeddedObject curAttachment = curDoc.getAttachment(curAttName);
if (curAttachment == null) {
LOGGER.info("�ttachment is null");
}
File tempFile = this.getTempfile();
// Delete if it exists
if (tempFile.exists()) {
tempFile.delete();
}
curAttachment.extractFile(tempFile.getAbsolutePath());
LOGGER.info("Current attachment path extracted is ="
+ tempFile.getAbsolutePath());
curStream = new CategorizedDocumentInputStream(tempFile, this);
} catch (Exception e) {
LOGGER.error(e);
}
}
return curStream;
}