use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class DocumentsModifiedDuringDistributionListener method checkXARHandler.
private void checkXARHandler(Event event, XWikiDocument document, XWikiContext xcontext) {
ExecutionContext context = this.execution.getContext();
if (context != null) {
XarExtensionPlan xarExtensionPlan = (XarExtensionPlan) context.getProperty(XarExtensionPlan.CONTEXTKEY_XARINSTALLPLAN);
if (xarExtensionPlan != null) {
Request request = this.jobContext.getCurrentJob().getRequest();
// It's a job started by the Distribution Wizard
if (StringUtils.equals(request.<String>getProperty("context.action"), "distribution")) {
String distributionWiki = request.getProperty("context.wiki");
if (distributionWiki != null) {
DocumentReference reference = document.getDocumentReferenceWithLocale();
DocumentStatus.Action action = toAction(event);
LocalExtension previousExtension = xarExtensionPlan.getPreviousXarExtension(reference);
LocalExtension nextExtension = xarExtensionPlan.getNextXarExtension(reference);
addDocument(distributionWiki, document, action, previousExtension, nextExtension);
}
}
}
}
}
use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class DocumentsDeletingListener method checkIfPageBelongToExtensions.
private void checkIfPageBelongToExtensions(EntitySelection entitySelection, ExtensionBreakingQuestion question) {
XarInstalledExtensionRepository repository = (XarInstalledExtensionRepository) installedExtensionRepository;
DocumentReference documentReference = (DocumentReference) entitySelection.getEntityReference();
Collection<XarInstalledExtension> extensions = repository.getXarInstalledExtensions(documentReference);
if (extensions.isEmpty()) {
question.markAsFreePage(entitySelection);
return;
}
for (XarInstalledExtension extension : extensions) {
question.pageBelongsToExtension(entitySelection, extension);
}
}
use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class AbstractExtensionDistributionStep method install.
protected void install(ExtensionId extensionId, String namespace, boolean jarOnRoot) throws JobException, InterruptedException {
// Install the default UI
InstallRequest installRequest = new InstallRequest();
installRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_ACTION_PREFIX, extensionId.getId(), namespace));
installRequest.addExtension(extensionId);
installRequest.addNamespace(namespace);
// Indicate it's allowed to do modification on root namespace
installRequest.setRootModificationsAllowed(true);
// Make sure the job is no interactive
installRequest.setInteractive(false);
if (jarOnRoot) {
// Make sure jars are installed on root
// TODO: use a less script oriented class
ScriptExtensionRewriter rewriter = new ScriptExtensionRewriter();
rewriter.installExtensionTypeOnRootNamespace("jar");
rewriter.installExtensionTypeOnRootNamespace("webjar");
installRequest.setRewriter(rewriter);
}
// Set the author to use
installRequest.setProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, new DocumentReference("xwiki", "XWiki", XWikiRightService.SUPERADMIN_USER));
installRequest.setExtensionProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, XWikiRightService.SUPERADMIN_USER_FULLNAME);
this.jobExecutor.execute(InstallJob.JOBTYPE, installRequest).join();
}
use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class DocumentTreeNodeTest method pagination.
/**
* @see "XWIKI-14643: Missing page in breadcrumbs treeview when treeview is expanded"
*/
@Test
public void pagination() throws Exception {
TreeNode documentTreeNode = this.mocker.getComponentUnderTest();
documentTreeNode.getProperties().put("hierarchyMode", "reference");
documentTreeNode.getProperties().put("showTranslations", true);
documentTreeNode.getProperties().put("showAttachments", true);
documentTreeNode.getProperties().put("showClassProperties", true);
documentTreeNode.getProperties().put("showObjects", true);
documentTreeNode.getProperties().put("showAddDocument", true);
when(this.authorization.hasAccess(Right.EDIT, documentReference.getParent())).thenReturn(true);
when(this.translationsTreeNode.getChildCount("translations:wiki:Path.To.Page.WebHome")).thenReturn(1);
when(this.attachmentsTreeNode.getChildCount("attachments:wiki:Path.To.Page.WebHome")).thenReturn(1);
when(this.classPropertiesTreeNode.getChildCount("classProperties:wiki:Path.To.Page.WebHome")).thenReturn(1);
when(this.objectsTreeNode.getChildCount("objects:wiki:Path.To.Page.WebHome")).thenReturn(1);
assertEquals(Arrays.asList("translations:wiki:Path.To.Page.WebHome", "attachments:wiki:Path.To.Page.WebHome", "classProperties:wiki:Path.To.Page.WebHome"), documentTreeNode.getChildren("document:wiki:Path.To.Page.WebHome", 0, 3));
verify(this.nestedPagesOrderedByName, never()).execute();
DocumentReference alice = new DocumentReference("wiki", Arrays.asList("Path.To.Page"), "Alice");
when(this.nestedPagesOrderedByName.execute()).thenReturn(Collections.singletonList(alice));
when(this.defaultEntityReferenceSerializer.serialize(alice)).thenReturn("wiki:Path.To.Page.Alice");
assertEquals(Arrays.asList("objects:wiki:Path.To.Page.WebHome", "addDocument:wiki:Path.To.Page.WebHome", "document:wiki:Path.To.Page.Alice"), documentTreeNode.getChildren("document:wiki:Path.To.Page.WebHome", 3, 3));
verify(this.nestedPagesOrderedByName).setOffset(0);
verify(this.nestedPagesOrderedByName).setLimit(1);
DocumentReference bob = new DocumentReference("wiki", Arrays.asList("Path.To.Page"), "Bob");
DocumentReference carol = new DocumentReference("wiki", Arrays.asList("Path.To.Page"), "Carol");
when(this.nestedPagesOrderedByName.execute()).thenReturn(Arrays.asList(bob, carol));
when(this.defaultEntityReferenceSerializer.serialize(bob)).thenReturn("wiki:Path.To.Page.Bob");
when(this.defaultEntityReferenceSerializer.serialize(carol)).thenReturn("wiki:Path.To.Page.Carol");
assertEquals(Arrays.asList("document:wiki:Path.To.Page.Bob", "document:wiki:Path.To.Page.Carol"), documentTreeNode.getChildren("document:wiki:Path.To.Page.WebHome", 6, 3));
verify(this.nestedPagesOrderedByName).setOffset(1);
verify(this.nestedPagesOrderedByName).setLimit(3);
}
use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class DocumentTreeNode method getChildDocuments.
@Override
protected List<DocumentReference> getChildDocuments(DocumentReference documentReference, int offset, int limit) throws QueryException {
Query query = getChildDocumentsQuery(documentReference);
query.setOffset(offset);
query.setLimit(limit);
List<DocumentReference> documentReferences = new ArrayList<DocumentReference>();
for (Object result : query.execute()) {
documentReferences.add(this.explicitDocumentReferenceResolver.resolve((String) result, documentReference));
}
return documentReferences;
}
Aggregations