use of com.xpn.xwiki.store.XWikiAttachmentStoreInterface in project xwiki-platform by xwiki.
the class XWikiAttachment method loadAttachmentContent.
public void loadAttachmentContent(XWikiContext xcontext) throws XWikiException {
if (this.content == null) {
WikiReference currentWiki = xcontext.getWikiReference();
try {
// Make sure we work on the attachment's wiki
WikiReference attachmentWiki = getReference().getDocumentReference().getWikiReference();
if (attachmentWiki != null) {
xcontext.setWikiReference(attachmentWiki);
}
try {
XWikiAttachmentStoreInterface store = getAttachmentContentStore(xcontext);
store.loadAttachmentContent(this, xcontext, true);
} catch (ComponentLookupException e) {
throw new XWikiException("Failed to find store for attachment [" + getReference() + "]", e);
}
} finally {
if (currentWiki != null) {
xcontext.setWikiReference(currentWiki);
}
}
}
}
use of com.xpn.xwiki.store.XWikiAttachmentStoreInterface in project xwiki-platform by xwiki.
the class XWikiDocument method saveAttachmentContent.
/**
* @deprecated should not be used, save the document instead
*/
@Deprecated
public void saveAttachmentContent(XWikiAttachment attachment, boolean updateParent, boolean transaction, XWikiContext context) throws XWikiException {
String currentWiki = context.getWikiId();
try {
// get the translated content
if (getDatabase() != null) {
context.setWikiId(getDatabase());
}
// Save the attachment
XWikiAttachmentStoreInterface store = resolveXWikiAttachmentStoreInterface(attachment.getContentStore(), context);
store.saveAttachmentContent(attachment, false, context, transaction);
// We need to make sure there is a version upgrade
setMetaDataDirty(true);
// Save the document
if (updateParent) {
context.getWiki().saveDocument(this, context);
}
} catch (OutOfMemoryError e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_JAVA_HEAP_SPACE, "Out Of Memory Exception");
} finally {
if (currentWiki != null) {
context.setWikiId(currentWiki);
}
}
}
Aggregations