/** * Creates a {@link WikiReference} from a string representing the wiki name. * * @param wikiName the wiki name (eg "xwiki") * @return the reference to the wiki * @since 5.0M1 */ public WikiReference createWikiReference(String wikiName) { return new WikiReference(wikiName); }
/** * Create a new Document reference from wiki, space and page name. * * @param wikiName the name of the wiki containing the document, must not be null * @param spaceName the name of the space containing the document, must not be null * @param pageName the name of the document */ public DocumentReference(String wikiName, String spaceName, String pageName) { this(pageName, new SpaceReference(spaceName, new WikiReference(wikiName))); }
/** * Create a new Document reference from wiki name, space name, page name and locale. * * @param wikiName the name of the wiki containing the document, must not be null * @param spaceName the name of the space containing the document, must not be null * @param pageName the name of the document * @param locale the locale of the document reference, may be null */ public DocumentReference(String wikiName, String spaceName, String pageName, Locale locale) { this(pageName, new SpaceReference(spaceName, new WikiReference(wikiName)), locale); }
/** * Create a space reference based on a space name and a parent space reference. * * @param wikiName the name of the wiki * @param spaceNames the spaces names * @since 7.4M1 */ public SpaceReference(String wikiName, List<String> spaceNames) { this(spaceNames.get(spaceNames.size() - 1), spaceNames.size() > 1 ? new SpaceReference(wikiName, spaceNames.subList(0, spaceNames.size() - 1)) : new WikiReference(wikiName)); }
public void addWiki(String wikiId, boolean deleted) { if (wikiId != null) { this.queue.add(new WikiData(new WikiReference(wikiId), deleted)); } else { LOGGER.error("Invalid parameters given to {} wiki [{}]", (deleted ? "deleted" : "added"), wikiId); } }
/** * @return the original wiki reference used when this security reference was built. Null if this is not * the reference to a wiki. */ public WikiReference getOriginalWikiReference() { return (this.getType() == EntityType.WIKI) ? (this.originalReference instanceof WikiReference) ? (WikiReference) this.originalReference : new WikiReference(this.originalReference) : null; }
/** * Create a page reference based on a page name and a parent page reference. * * @param wikiName the name of the wiki * @param pageNames the pages names */ public PageReference(String wikiName, List<String> pageNames) { this(pageNames.get(pageNames.size() - 1), pageNames.size() > 1 ? new PageReference(wikiName, pageNames.subList(0, pageNames.size() - 1)) : new WikiReference(wikiName)); }
/** * @return a reference to that wiki */ public WikiReference getReference() { return new WikiReference(getId()); }
@Override public WikiReference getMainWikiReference() { if (mainWikiReference == null) { mainWikiReference = new WikiReference(xcontextProvider.get().getMainXWiki()); } return mainWikiReference; }
/** * @return a reference to the main page of the wiki */ public DocumentReference getMainPageReference() { return new DocumentReference(mainPageReference, new WikiReference(getId())); }
/** * @return the reference pointing to the current wiki */ protected WikiReference getCurrentWikiReference() { return new WikiReference(this.wikiManager.getCurrentWikiId()); }
/** * @return the reference pointing to the current wiki */ protected WikiReference getCurrentWikiReference() { EntityReference wikiReference = this.entityReferenceProvider.getDefaultReference(EntityType.WIKI); return wikiReference instanceof WikiReference ? (WikiReference) wikiReference : new WikiReference(wikiReference); } }
private List<DocumentReference> getSubscriberReferences(Collection<String> subscribers) { List<DocumentReference> result = new ArrayList<>(); XWikiContext context = contextProvider.get(); WikiReference currentWikiReference = new WikiReference(context.getWikiId()); for (String subscriber : subscribers) { DocumentReference subscriberReference = explicitDocumentReferenceResolver.resolve(subscriber, currentWikiReference); result.add(subscriberReference); } return result; }
private String getFullReference(String userId, String wikiId) { String result = null; if (!StringUtils.isBlank(userId)) { DocumentReference userReference = userReferenceResolver.resolve(userId, new WikiReference(wikiId)); result = referenceSerializer.serialize(userReference); } return result; }
@Override public WikiReference get() { if (this.cachedReference == null) { EntityReference reference = this.provider.getDefaultReference(EntityType.WIKI); this.cachedReference = this.factory.getReference( reference instanceof WikiReference ? (WikiReference) reference : new WikiReference(reference)); } return this.cachedReference; } }
private boolean isSpaceEnabled(String wiki, String space) { return this.properties.getEntities() == null || this.properties.getEntities().matches(new SpaceReference(space, new WikiReference(wiki))); }
@Override public boolean hasWikiAdminRights(XWikiContext context) { return contextualAuthorizationManager.hasAccess(Right.ADMIN, new WikiReference(context.getWikiId())); }
/** * @since 7.2RC1 */ public String getSpaces() { return getUtil().serializeReference( this.homeReference.extractReference(EntityType.SPACE).removeParent(new WikiReference("xwiki"))); }
/** * Transform a username into a document reference, belonging to the current wiki. * * @param identifier the user identifier to resolve * @return a document reference */ private DocumentReference getLocalReference(String identifier) { WikiReference currentWiki = new WikiReference(this.modelContext.getCurrentEntityReference().getRoot()); return new DocumentReference(this.nameResolver.resolve(identifier, EntityType.DOCUMENT, new EntityReference(this.defaultSpace, EntityType.SPACE, currentWiki))); }
@Override public boolean hasAccessLevel(String right, String username, String docname, XWikiContext context) throws XWikiException { User user = this.userManager.getUser(StringUtils.endsWith(username, "XWikiGuest") ? null : username, true); WikiReference wikiReference = new WikiReference(context.getWikiId()); DocumentReference document = resolveDocumentName(docname, wikiReference); return this.service.hasAccess(user, Right.toRight(right), document); }