use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class ObjectsOfTypeTreeNode method getXObjectReferences.
private List<ObjectReference> getXObjectReferences(DocumentReference documentReference, DocumentReference classReference) throws Exception {
XWikiContext xcontext = this.xcontextProvider.get();
XWikiDocument document = xcontext.getWiki().getDocument(documentReference, xcontext);
List<ObjectReference> objectReferences = new ArrayList<ObjectReference>();
List<BaseObject> objects = document.getXObjects(classReference);
if (objects != null) {
for (BaseObject object : objects) {
// Yes, the list of objects can contain null values..
if (object != null) {
objectReferences.add(object.getReference());
}
}
}
return objectReferences;
}
use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class DefaultMessageStream method postMessageToGroup.
@Override
public void postMessageToGroup(String message, DocumentReference group) throws IllegalAccessError {
if (!this.bridge.exists(group)) {
throw new IllegalArgumentException("Target group does not exist");
}
Event e = createMessageEvent(message, "groupMessage");
e.setRelatedEntity(new ObjectReference("XWiki.XWikiGroups", group));
e.setStream(this.serializer.serialize(group));
e.setImportance(Importance.MAJOR);
this.stream.addEvent(e);
}
use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class MessageStreamTest method testPostGroupMessage.
@Test
public void testPostGroupMessage() throws Exception {
Event postedMessage = setupForGroupMessage();
this.stream.postMessageToGroup("Hello Friends!", this.targetGroup);
Assert.assertEquals("Hello Friends!", postedMessage.getBody());
Assert.assertEquals(Importance.MAJOR, postedMessage.getImportance());
Assert.assertEquals("groupMessage", postedMessage.getType());
Assert.assertEquals("wiki:XWiki.MyFriends", postedMessage.getStream());
Assert.assertEquals(new ObjectReference("XWiki.XWikiGroups", this.targetGroup), postedMessage.getRelatedEntity());
}
use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class XWikiTest method testGetDocumentWithEntityReference.
public void testGetDocumentWithEntityReference() throws Exception {
Mock mockStore = registerMockComponent(XWikiStoreInterface.class);
this.xwiki.setStore((XWikiStoreInterface) mockStore.proxy());
mockStore.expects(atLeastOnce()).method("loadXWikiDoc").with(NOT_NULL, same(getContext())).will(new CustomStub("Implements XWikiStoreInterface.loadXWikiDoc") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
return invocation.parameterValues.get(0);
}
});
DocumentReference documentReference = new DocumentReference("wiki", "Main", "WebHome");
WikiDescriptor mockWikiDescriptor = new WikiDescriptor("wiki", "wiki");
mockWikiDescriptor.setMainPageReference(documentReference);
this.mockWikiDescriptorManager.stubs().method("getById").with(same("wiki")).will(returnValue(mockWikiDescriptor));
assertEquals(documentReference, this.xwiki.getDocument(new WikiReference("wiki"), getContext()).getDocumentReference());
assertEquals(documentReference, this.xwiki.getDocument(new ObjectReference("object", documentReference), getContext()).getDocumentReference());
}
use of org.xwiki.model.reference.ObjectReference in project xwiki-platform by xwiki.
the class TestUtils method disableSyntaxHighlighting.
/**
* Disable Syntax Highlighting.
*
* @since 9.7RC1
*/
public void disableSyntaxHighlighting() throws Exception {
ObjectPropertyReference enabledPropertyReference = new ObjectPropertyReference("enabled", new ObjectReference("SyntaxHighlighting.ConfigurationClass[0]", new DocumentReference(getCurrentWiki(), "SyntaxHighlighting", "Configuration")));
Property property = new Property();
property.setValue("0");
TestUtils.assertStatusCodes(rest().executePut(ObjectPropertyResource.class, property, rest().toElements(enabledPropertyReference)), true, STATUS_ACCEPTED);
}
Aggregations