/** * @param documentReference the full document reference * @since 5.2M2 */ public LocalDocumentReference(DocumentReference documentReference) { super(documentReference, documentReference.getWikiReference(), null); }
@Override public WikiReference getWiki() { WikiReference result = null; if (this.wiki != null) { result = this.wiki; } else if (this.space != null) { result = (WikiReference) this.space.getRoot(); } else if (this.document != null) { result = this.document.getWikiReference(); } return result; }
/** * Note that this method cannot be removed for now since it's used by Hibernate for saving a XWikiDocument. * * @deprecated since 2.2M1 use {@link #getDocumentReference()} instead */ @Deprecated public String getDatabase() { return getDocumentReference().getWikiReference().getName(); }
/** * Note that this method cannot be removed for now since it's used by Hibernate for loading a XWikiDocument. * * @deprecated since 2.2M1 use {@link #setDocumentReference(DocumentReference)} instead */ @Deprecated public void setDatabase(String database) { if (database != null) { getDocumentReference().getWikiReference().setName(database); // Clean the absolute parent reference cache to rebuild it next time getParentReference is called. this.parentReferenceCache = null; } }
/** * Get the name wiki where the document is stored. * * @return The name of the wiki where this document is stored. * @since XWiki Core 1.1.2, XWiki Core 1.2M2 */ public String getWiki() { return this.doc.getDocumentReference().getWikiReference().getName(); }
/** * @return The wiki in which the event happened. */ public String getWiki() { return getDocumentReference().getWikiReference().getName(); }
/** * Ensure that the given author has the administrative rights in the current context. * * @param documentReference the working entity * @param authorReference the author that should have its rights checked * @throws NotificationException if the author rights are not sufficient */ private void checkRights(DocumentReference documentReference, DocumentReference authorReference) throws NotificationException { if (!this.authorizationManager.hasAccess(Right.ADMIN, authorReference, documentReference.getWikiReference())) { throw new NotificationException( "Registering custom Notification Filter Displayers requires wiki administration rights."); } } }
/** * @return true for global user * @since 5.0M2 */ public boolean isGlobal() { DocumentReference ref = this.getOriginalReference(); return (ref == null) || ref.getWikiReference().equals(mainWikiReference.getOriginalWikiReference()); } }
private void addImpliedGlobalRule(DocumentReference documentReference, List<SecurityRule> rules) throws AuthorizationException { WikiReference documentWiki = documentReference.getWikiReference(); DocumentReference owner = getWikiOwner(documentWiki); if (owner != null) { XWikiContext context = getXWikiContext(); // Allow global rights to wiki owner if (context.isMainWiki(documentWiki.getName())) { rules.add( new XWikiSecurityRule(MAINWIKIOWNER_RIGHTS, RuleState.ALLOW, Collections.singleton(owner), null)); } else { rules.add(new XWikiSecurityRule(OWNER_RIGHTS, RuleState.ALLOW, Collections.singleton(owner), null)); } } }
/** * @return true if the Message Stream feature is active or false otherwise * @since 8.4RC1 */ public boolean isActive() { return messageStreamConfiguration.isActive( documentAccessBridge.getCurrentDocumentReference().getWikiReference().getName() ); }
private void clearCache(XWikiDocument document) { DocumentReference documentReference = document.getDocumentReference(); // Clear the cache for the specified wiki and color theme String wiki = documentReference.getWikiReference().getName(); lessSkinFileCache.clear(wiki); colorThemeCache.clear(wiki); } }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getDocumentName(String) */ @Deprecated public org.xwiki.bridge.DocumentName getDocumentName(String documentReference) { DocumentReference docReference = this.currentMixedDocumentReferenceResolver.resolve(documentReference); return new org.xwiki.bridge.DocumentName(docReference.getWikiReference().getName(), docReference.getLastSpaceReference().getName(), docReference.getName()); }
private void initialize() { this.events = Arrays.<Event>asList(new DocumentUpdatedEvent(this.documentReference), new DocumentCreatedEvent( this.documentReference), new DocumentDeletedEvent(this.documentReference), new WikiDeletedEvent( this.documentReference.getWikiReference().getName())); this.observation.addListener(this); }
public XWikiDocument getDocument(XWikiDocument doc, XWikiContext context) throws XWikiException { String database = context.getDatabase(); try { if (doc.getDocumentReference().getWikiReference().getName() != null) { context.setDatabase(doc.getDocumentReference().getWikiReference().getName()); } return getStore().loadXWikiDoc(doc, context); } finally { context.setDatabase(database); } }
@Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = super.updateDocument(document); // Use PanelSheet to display documents having PanelClass objects if no other class sheet is specified. if (this.classSheetBinder.getSheets(document).isEmpty()) { String wikiName = document.getDocumentReference().getWikiReference().getName(); DocumentReference sheet = new DocumentReference(wikiName, CLASS_SPACE, "PanelSheet"); needsUpdate |= this.classSheetBinder.bind(document, sheet); } return needsUpdate; } }
@Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = super.updateDocument(document); // Use XWikiServerClassSheet to display documents having XWikiServerClass objects if no other class sheet is // specified. if (this.classSheetBinder.getSheets(document).isEmpty()) { String wikiName = document.getDocumentReference().getWikiReference().getName(); DocumentReference sheet = new DocumentReference(wikiName, XWiki.SYSTEM_SPACE, "XWikiServerClassSheet"); needsUpdate |= this.classSheetBinder.bind(document, sheet); } return needsUpdate; } }
@Override public boolean updateDocument(XWikiDocument document) { super.updateDocument(document); // Use SchedulerJobSheet to display documents having SchedulerJobClass objects if no other class sheet is // specified. if (this.classSheetBinder.getSheets(document).isEmpty()) { String wikiName = document.getDocumentReference().getWikiReference().getName(); DocumentReference sheet = new DocumentReference(wikiName, XWiki.SYSTEM_SPACE, SHEET_NAME); return this.classSheetBinder.bind(document, sheet); } return false; } }
/** * Transforms a XClass reference relative to this document into an absolute reference. */ private DocumentReference resolveClassReference(EntityReference reference) { DocumentReference defaultReference = new DocumentReference(getDocumentReference().getWikiReference().getName(), XWiki.SYSTEM_SPACE, getDocumentReference().getName()); return this.explicitReferenceDocumentReferenceResolver.resolve(reference, defaultReference); }
/** * Backward-compatibility method to use in order to resolve a class reference passed as a String into a * DocumentReference proper. * * @return the resolved class reference but using this document's wiki if the passed String doesn't specify a wiki, * the "XWiki" space if the passed String doesn't specify a space and this document's page if the passed * String doesn't specify a page. */ public DocumentReference resolveClassReference(String documentName) { DocumentReference defaultReference = new DocumentReference(getDocumentReference().getWikiReference().getName(), XWiki.SYSTEM_SPACE, getDocumentReference().getName()); return this.explicitDocumentReferenceResolver.resolve(documentName, defaultReference); }
/** * Generate a {@link Link} object from {@link DocumentReference} to be used in * {@link DocumentParser#parseLinksAndReplace(String, Link, Link, com.xpn.xwiki.content.parsers.ReplaceLinkHandler, String)} * * @param documentReference the full document reference * @return a {@link Link} */ private Link createLink(DocumentReference documentReference) { Link link = new Link(); link.setVirtualWikiAlias(documentReference.getWikiReference().getName()); link.setSpace(documentReference.getLastSpaceReference().getName()); link.setPage(documentReference.getName()); return link; }