use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class PathWikiReferenceExtractorTest method testAndAssert.
private void testAndAssert(String urlToTest, String expectedWikiId) throws Exception {
ExtendedURL url = new ExtendedURL(new URL(urlToTest), "xwiki");
// Remove the resource type (i.e. the first segment) since this is what is expected by the extractor
url.getSegments().remove(0);
WikiReference wikiReference = this.mocker.getComponentUnderTest().extract(url);
assertEquals(new WikiReference(expectedWikiId), wikiReference);
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class BinEntityResourceReferenceResolverTest method buildEntityReference.
private EntityReference buildEntityReference(String wiki, List<String> spaces, String page, String attachment) {
EntityReference entityReference = new WikiReference(wiki);
if (spaces != null) {
EntityReference parent = entityReference;
for (String space : spaces) {
entityReference = new EntityReference(space, EntityType.SPACE, parent);
parent = entityReference;
}
}
if (page != null) {
entityReference = new EntityReference(page, EntityType.DOCUMENT, entityReference);
}
if (attachment != null) {
entityReference = new EntityReference(attachment, EntityType.ATTACHMENT, entityReference);
}
return entityReference;
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class Exporter method exportDocuments.
/**
* Export documents from an existing loaded XWiki database. The database is defined by its passed name and by an
* Hibernate configuration file.
*
* @param exportDirectory the directory where to export the documents
* @param wikiId the wiki to export
* @throws Exception if the export failed for any reason
*/
public void exportDocuments(File exportDirectory, String wikiId) throws Exception {
WikiReference currentWikiReference = this.oldCoreHelper.getXWikiContext().getWikiReference();
try {
this.oldCoreHelper.getXWikiContext().setWikiId(wikiId);
// TODO: Use Filter framework instead
Package pack = new Package();
pack.setWithVersions(false);
pack.addAllWikiDocuments(this.oldCoreHelper.getXWikiContext());
// See https://jira.xwiki.org/browse/XWIKI-458
try {
pack.exportToDir(exportDirectory, this.oldCoreHelper.getXWikiContext());
} catch (IOException e) {
throw new PackageException(PackageException.ERROR_PACKAGE_UNKNOWN, "Failed to export documents to [" + exportDirectory + "]", e);
}
} finally {
this.oldCoreHelper.getXWikiContext().setWikiReference(currentWikiReference);
}
}
use of org.xwiki.model.reference.WikiReference in project xwiki-platform by xwiki.
the class AbstractValidationTest method readXarContents.
protected static List<DocumentReference> readXarContents(String fileName, String patternFilter) throws Exception {
Collection<XarEntry> entries = XarPackage.getEntries(new File(fileName));
List<DocumentReference> result = new ArrayList<DocumentReference>(entries.size());
WikiReference wikiReference = new WikiReference("xwiki");
Pattern pattern = patternFilter == null ? null : Pattern.compile(patternFilter);
for (XarEntry entry : entries) {
if (pattern == null || pattern.matcher(SERIALIZER.serialize(entry)).matches()) {
result.add(new DocumentReference(entry, wikiReference));
}
}
return result;
}
use of org.xwiki.model.reference.WikiReference in project celements-blog by celements.
the class ArticleLuceneQueryBuilder method build.
@Override
public LuceneQuery build(ArticleLoadParameter param) throws XWikiException {
LuceneQuery query = null;
if (param.getBlogDocRef() != null) {
QueryRestrictionGroup blogOrSubsGrp = searchService.createRestrictionGroup(Type.OR);
blogOrSubsGrp.add(getBlogRestriction(param));
blogOrSubsGrp.add(getSubsRestrictions(param));
if (!blogOrSubsGrp.isEmpty()) {
WikiReference wikiRef = param.getBlogDocRef().getWikiReference();
query = searchService.createQuery();
query.setWiki(wikiRef);
query.add(getBlogSearchTermRestriction(param));
DocumentReference articleClassRef = getBlogClasses().getArticleClassRef(wikiRef.getName());
query.add(searchService.createObjectRestriction(articleClassRef));
if (StringUtils.isNotBlank(param.getLanguage())) {
query.add(searchService.createFieldRestriction(articleClassRef, BlogClasses.PROPERTY_ARTICLE_LANG, "\"" + param.getLanguage() + "\""));
}
query.add(blogOrSubsGrp);
}
}
LOGGER.info("Built '" + query + "' for '" + param + "'");
return query;
}
Aggregations