@Override protected EntityReference getDefaultReference(EntityType type, Object... parameters) { return currentEntityReferenceProvider.getDefaultReference(type); } }
@Override protected EntityReference getDefaultReference(EntityType type, Object... parameters) { if (type == EntityType.SPACE) { return XWikiConstants.XWIKI_SPACE_REFERENCE; } else { return this.provider.getDefaultReference(type); } } }
@Override protected EntityReference getDefaultReference(EntityType type, Object... parameters) { return this.provider.getDefaultReference(type); } }
@Override protected EntityReference getDefaultReference(EntityType type, Object... parameters) { return this.provider.getDefaultReference(type); } }
@Override protected EntityReference getDefaultReference(EntityType type, Object... parameters) { if (type == EntityType.SPACE) { return XWikiConstants.XWIKI_SPACE_REFERENCE; } else { return this.provider.getDefaultReference(type); } } }
/** * @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 String getDefaultDocumentName() { return this.defaultProvider.getDefaultReference(EntityType.DOCUMENT).getName(); }
/** * Get the reference configured for a specific entity type, like the space reference or wiki reference. This doesn't * return a full entity reference, but just the part that should be used for that type of entity. * * @param type the target entity type; from Velocity it's enough to use a string with the uppercase name of the * entity, like {@code 'SPACE'} * @param hint the hint of the {@link EntityReferenceProvider} to use (valid hints are for example "default", * "current" and "currentmixed") * @return the configured value for the requested entity type, for example "Main" for the default space or "WebHome" * for the default space homepage * @since 7.2M1 */ public EntityReference getEntityReference(EntityType type, String hint) { if (type == null) { return null; } try { EntityReferenceProvider provider = this.componentManager.getInstance(EntityReferenceProvider.class, hint); return provider.getDefaultReference(type); } catch (ComponentLookupException ex) { return null; } }
@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; } }
protected boolean isSpaceHomeReference(DocumentReference documentReference) { return documentReference.getName() .equals(this.defaultEntityReferenceProvider.getDefaultReference(documentReference.getType()).getName()); }
@Override public DocumentReference get() { if (this.cachedReference == null) { EntityReference reference = this.provider.getDefaultReference(EntityType.DOCUMENT); // Add spaces reference = reference.appendParent(this.spaceReferenceProvider.get()); this.cachedReference = this.factory.getReference(new DocumentReference(reference)); } return this.cachedReference; } }
@Override public PageReference get() { if (this.cachedReference == null) { EntityReference reference = this.provider.getDefaultReference(EntityType.PAGE); // Add wiki reference = reference.appendParent(this.wikiReferenceProvider.get()); this.cachedReference = this.factory.getReference(new PageReference(reference)); } return this.cachedReference; } }
@Override public SpaceReference get() { if (this.cachedReference == null) { EntityReference reference = this.provider.getDefaultReference(EntityType.SPACE); // Add wikis reference = reference.appendParent(this.wikiReferenceProvider.get()); this.cachedReference = this.factory.getReference(new SpaceReference(reference)); } return this.cachedReference; } }
/** * @param document an XWiki document * @return the title used as a fall-back when the dynamic title cannot be evaluated */ private XDOM getStaticTitle(DocumentModelBridge document) { String documentName = document.getDocumentReference().getName(); if (defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT).getName().equals(documentName)) { // This document represents a space (it is the home page of a space). Use the space name instead. documentName = document.getDocumentReference().getParent().getName(); } return parseTitle(documentName); }
/** * Schedules an asynchronous job to convert the specified terminal document to a nested document (that can have * child documents). E.g. the document {@code Space1.Space2.Name} is converted to {@code Space1.Space2.Name.WebHome} * . * * @param documentReference the terminal document to convert to a nested document (that can have child documents) * @return the job that has been scheduled and that can be used to monitor the progress of the operation, * {@code null} in case of failure */ public Job convertToNestedDocument(DocumentReference documentReference) { String defaultDocName = this.defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT).getName(); if (!documentReference.getName().equals(defaultDocName)) { SpaceReference spaceReference = new SpaceReference(documentReference.getName(), documentReference.getParent()); return rename(documentReference, new DocumentReference(defaultDocName, spaceReference)); } // The specified document is already a nested document. return null; }
private DocumentReference getHierarchicalParent(DocumentReference documentReference) { final String spaceHomePage = entityReferenceProvider.getDefaultReference(EntityType.DOCUMENT).getName(); EntityReference parentOfTheSpace = documentReference.getLastSpaceReference().getParent(); boolean pageIsNotTerminal = documentReference.getName().equals(spaceHomePage); // Case 1: The document has the location A.B.C.WebHome // The parent should be A.B.WebHome if (pageIsNotTerminal && parentOfTheSpace.getType() == EntityType.SPACE) { return new DocumentReference(spaceHomePage, new SpaceReference(parentOfTheSpace)); } // Case 2: The document has the location A.WebHome // The parent should be Main.WebHome if (pageIsNotTerminal && parentOfTheSpace.getType() == EntityType.WIKI) { return new DocumentReference(spaceHomePage, new SpaceReference(entityReferenceProvider.getDefaultReference(EntityType.SPACE).getName(), documentReference.getWikiReference())); } // Case 3: The document has the location A.B // The parent should be A.WebHome return new DocumentReference(spaceHomePage, documentReference.getLastSpaceReference()); }
/** * @return the serialized space for display, taking into account Nested Pages, i.e. not displaying WebHome for a * nicer user experience * @since 8.3M2 */ public String getDisplaySpace() { if (getDefaultEntityReferenceProvider().getDefaultReference(EntityType.DOCUMENT).getName().equals( getDocumentReference().getName()) && getDocumentReference().getLastSpaceReference().getParent() != null) { return getLocalSerializer().serialize(getDocumentReference().getLastSpaceReference().getParent()); } else { return getSpace(); } }
/** * Schedules an asynchronous job to convert the specified nested document to a terminal document (that can't have * child documents). E.g. the document {@code One.Two.WebHome} is converted to {@code One.Two} . * * @param documentReference the nested document to convert to a terminal document (that can't have child documents) * @return the job that has been scheduled and that can be used to monitor the progress of the operation, * {@code null} in case of failure */ public Job convertToTerminalDocument(DocumentReference documentReference) { if (documentReference.getName().equals( this.defaultEntityReferenceProvider.getDefaultReference(documentReference.getType()).getName())) { EntityReference parentReference = documentReference.getParent(); if (parentReference.getParent().getType() == EntityType.SPACE) { // There has to be at least 2 levels of nested spaces in order to be able to convert a nested document // into a terminal document. We cannot convert a root document like Main.WebHome into a terminal // document. DocumentReference terminalDocumentReference = new DocumentReference(parentReference.getName(), new SpaceReference(parentReference.getParent())); return rename(documentReference, terminalDocumentReference); } } // The specified document is already a terminal document or cannot be converted to a terminal document. return null; }