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;
}
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;
}
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));
}
}
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);
}
}
}
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()));
}
Aggregations