Search in sources :

Example 16 with WikiReference

use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.

the class RefactoringScriptService method getCurrentWikiReference.

private WikiReference getCurrentWikiReference() {
    WikiReference result = null;
    EntityReference currentEntityReference = this.modelContext.getCurrentEntityReference();
    if (currentEntityReference != null) {
        EntityReference wikiEntityReference = this.modelContext.getCurrentEntityReference().extractReference(EntityType.WIKI);
        if (wikiEntityReference != null) {
            result = new WikiReference(wikiEntityReference);
        }
    }
    return result;
}
Also used : EntityReference(org.xwiki.model.reference.EntityReference) WikiReference(org.xwiki.model.reference.WikiReference)

Example 17 with WikiReference

use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.

the class Utils method getSpaceReference.

/**
 * @param spaces the space hierarchy
 * @param wikiName the name of the wiki
 * @return the space reference
 */
public static SpaceReference getSpaceReference(List<String> spaces, String wikiName) {
    EntityReference parentReference = new WikiReference(wikiName);
    SpaceReference spaceReference = null;
    for (String space : spaces) {
        spaceReference = new SpaceReference(space, parentReference);
        parentReference = spaceReference;
    }
    return spaceReference;
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) EntityReference(org.xwiki.model.reference.EntityReference) WikiReference(org.xwiki.model.reference.WikiReference)

Example 18 with WikiReference

use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.

the class R910100XWIKI14871DataMigration method getEntityReference.

private EntityReference getEntityReference(File directory) throws IOException {
    String name = decode(directory.getName());
    File root = this.fstools.getStorageLocationFile();
    File parent = directory.getParentFile();
    if (parent.getCanonicalPath().equals(root.getCanonicalPath())) {
        return new WikiReference(name);
    } else {
        return new SpaceReference(name, getEntityReference(parent));
    }
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) WikiReference(org.xwiki.model.reference.WikiReference) File(java.io.File)

Example 19 with WikiReference

use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.

the class AbstractXWIKI14697DataMigration method setStore.

private void setStore(List<Object[]> attachments, Session session) {
    WikiReference wikiReference = getXWikiContext().getWikiReference();
    List<Long> fileAttachments = new ArrayList<>(attachments.size());
    List<Long> configuredAttachments = new ArrayList<>(attachments.size());
    for (Object[] attachment : attachments) {
        Long id = (Long) attachment[0];
        String filename = (String) attachment[1];
        String fullName = (String) attachment[2];
        DocumentReference documentReference = this.resolver.resolve(fullName, wikiReference);
        AttachmentReference attachmentReference = new AttachmentReference(filename, documentReference);
        if (isFile(attachmentReference)) {
            fileAttachments.add(id);
        } else {
            configuredAttachments.add(id);
        }
    }
    // Set file store
    setStore(session, fileAttachments, FileSystemStoreUtils.HINT);
    // Set configured store
    if (!configuredAttachments.isEmpty()) {
        String configuredStore = this.configuration.getProperty("xwiki.store.attachment.hint");
        if (configuredStore != null) {
            setStore(session, configuredAttachments, configuredStore);
        } else {
            this.logger.warn("The following attachment with the following ids have unknown store: ", configuredAttachments);
        }
    }
}
Also used : AttachmentReference(org.xwiki.model.reference.AttachmentReference) ArrayList(java.util.ArrayList) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 20 with WikiReference

use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.

the class WikiUserManagerScriptService method canSeeCandidacy.

private boolean canSeeCandidacy(MemberCandidacy candidacy) {
    XWikiContext context = xcontextProvider.get();
    // Test if the user is concerned by the candidacy...
    DocumentReference candidacyUser = documentReferenceResolver.resolve(candidacy.getUserId());
    if (context.getUserReference().equals(candidacyUser)) {
        // Hide the admin private comment
        candidacy.setAdminPrivateComment(null);
        return true;
    }
    // Otherwise the user must be an admin.
    return authorizationManager.hasAccess(Right.ADMIN, context.getUserReference(), new WikiReference(candidacy.getWikiId()));
}
Also used : XWikiContext(com.xpn.xwiki.XWikiContext) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

WikiReference (org.xwiki.model.reference.WikiReference)220 DocumentReference (org.xwiki.model.reference.DocumentReference)127 Test (org.junit.Test)106 SpaceReference (org.xwiki.model.reference.SpaceReference)58 XWikiContext (com.xpn.xwiki.XWikiContext)33 XWikiException (com.xpn.xwiki.XWikiException)24 EntityReference (org.xwiki.model.reference.EntityReference)24 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)23 ArrayList (java.util.ArrayList)19 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)18 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)15 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)11 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)10 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)10 XWiki (com.xpn.xwiki.XWiki)9 BaseObject (com.xpn.xwiki.objects.BaseObject)9 ComponentManager (org.xwiki.component.manager.ComponentManager)9 Expectations (org.jmock.Expectations)8 Before (org.junit.Before)8 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)8