/** * {@inheritDoc} * * @see com.xpn.xwiki.doc.XWikiDocument#getStore(com.xpn.xwiki.XWikiContext) */ @Override public XWikiStoreInterface getStore(XWikiContext context) { return getDocument().getStore(context); }
/** * {@inheritDoc} * * @see com.xpn.xwiki.doc.XWikiDocument#getStore() */ @Override public XWikiStoreInterface getStore() { return getDocument().getStore(); }
public List<String> getTranslationList(XWikiContext context) throws XWikiException { return getStore().getTranslationList(this, context); }
/** * @deprecated since 2.2M2 use {@link #getBackLinkedReferences(XWikiContext)} */ @Deprecated public List<String> getBackLinkedPages(XWikiContext context) throws XWikiException { return getStore(context).loadBacklinks(getFullName(), context, true); }
public XWikiLock getLock(XWikiContext context) throws XWikiException { XWikiLock theLock = getStore(context).loadLock(getId(), context, true); if (theLock != null) { int timeout = context.getWiki().getXWikiPreferenceAsInt("lock_Timeout", 30 * 60, context); if (theLock.getDate().getTime() + timeout * 1000 < new Date().getTime()) { getStore(context).deleteLock(theLock, context, true); theLock = null; } } return theLock; }
/** * Get the wiki document references pointing to this document. * <p> * Theses links are stored to the database when documents are saved. You can use "backlinks" in XWikiPreferences or * "xwiki.backlinks" in xwiki.cfg file to enable links storage in the database. * * @param context the XWiki context. * @return the found wiki document references * @throws XWikiException error when getting pages names from database. * @since 2.2M2 */ public List<DocumentReference> getBackLinkedReferences(XWikiContext context) throws XWikiException { return getStore(context).loadBacklinks(getDocumentReference(), true, context); }
public void setLock(String userName, XWikiContext context) throws XWikiException { XWikiLock lock = new XWikiLock(getId(), userName); getStore(context).saveLock(lock, context, true); }
public void refreshLinks(XWikiContext context) throws XWikiException { try { // refreshes all Links of each doc of the wiki List<String> docs = getStore().getQueryManager().getNamedQuery("getAllDocuments").execute(); for (int i = 0; i < docs.size(); i++) { XWikiDocument myDoc = this.getDocument(docs.get(i), context); myDoc.getStore().saveLinks(myDoc, context, true); } } catch (QueryException ex) { throw new XWikiException(0, 0, ex.getMessage(), ex); } }
/** * Gets the translated version of a document, in the specified language. If the translation does not exist, a new * document translation is created. If the requested language does not correspond to a translation (is not defined * or is the same as the main document), then the main document is returned. * * @param doc the main (default, untranslated) document to translate * @param language the requested document language * @param context the current request context * @return the translated document, or the original untranslated document if the requested language is not a * translation * @throws XWikiException if the translation cannot be retrieved from the database */ protected XWikiDocument getTranslatedDocument(XWikiDocument doc, String language, XWikiContext context) throws XWikiException { XWikiDocument tdoc; if (StringUtils.isBlank(language) || language.equals("default") || language.equals(doc.getDefaultLanguage())) { tdoc = doc; } else { tdoc = doc.getTranslatedDocument(language, context); if (tdoc == doc) { tdoc = new XWikiDocument(doc.getDocumentReference()); tdoc.setLanguage(language); tdoc.setStore(doc.getStore()); } tdoc.setTranslation(1); } return tdoc; }
links = new LinkedHashSet<XWikiLink>(getStore(context).loadLinks(getId(), context, true)); } else { Set<String> linkedPages = getUniqueLinkedPages(context);
public XWikiDocument getTranslatedDocument(String language, XWikiContext context) throws XWikiException { XWikiDocument tdoc = this; if (!((language == null) || (language.equals("")) || language.equals(getDefaultLanguage()))) { tdoc = new XWikiDocument(getDocumentReference()); tdoc.setLanguage(language); String database = context.getDatabase(); try { // We might need to switch database to // get the translated content if (getDatabase() != null) { context.setDatabase(getDatabase()); } tdoc = getStore(context).loadXWikiDoc(tdoc, context); if (tdoc.isNew()) { tdoc = this; } } catch (Exception e) { tdoc = this; } finally { context.setDatabase(database); } } return tdoc; }
session.setFlushMode(FlushMode.COMMIT); if (doc.getStore() == null) { Object[] args = {doc.getFullName()}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE,
/** * {@inheritDoc} */ public XWikiDocument loadXWikiDoc(XWikiDocument basedoc, String sversion, XWikiContext context) throws XWikiException { XWikiDocumentArchive archive = getXWikiDocumentArchive(basedoc, context); Version version = new Version(sversion); XWikiDocument doc = archive.loadDocument(version, context); if (doc == null) { Object[] args = {basedoc.getFullName(), version.toString()}; throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_UNEXISTANT_VERSION, "Version {1} does not exist while reading document {0}", null, args); } // Make sure the document has the same name // as the new document (in case there was a name change doc.setName(basedoc.getName()); doc.setSpace(basedoc.getSpace()); doc.setDatabase(basedoc.getDatabase()); doc.setStore(basedoc.getStore()); return doc; }
tdoc.setSyntax(doc.getSyntax()); tdoc.setAuthor(context.getUser()); tdoc.setStore(doc.getStore()); context.put("tdoc", tdoc); vcontext.put("tdoc", tdoc.newDocument(context));
tdoc.setSyntax(doc.getSyntax()); tdoc.setAuthor(context.getUser()); tdoc.setStore(doc.getStore()); context.put("tdoc", tdoc); vcontext.put("tdoc", tdoc.newDocument(context));
tdoc = new XWikiDocument(doc.getDocumentReference()); tdoc.setLanguage(language); tdoc.setStore(doc.getStore()); } else if (tdoc != doc) {
doc.setMostRecent(isMostRecent()); doc.setNew(isNew()); doc.setStore(getStore()); doc.setTemplateDocumentReference(getTemplateDocumentReference()); doc.setParentReference(getRelativeParentReference());
setMostRecent(document.isMostRecent()); setNew(document.isNew()); setStore(document.getStore()); setTemplateDocumentReference(document.getTemplateDocumentReference()); setParent(document.getParent());