use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class TestGroupUserFactory method getNewInstance.
@Override
TestGroup getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) throws SAXException {
EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"), parent.getType(), parent.getReference());
TestEntity entity = parser.getWikis().searchEntity(reference);
if (entity == null) {
throw new SAXException(parser.getLocatedMessage("User/Group [%s] is undefined.", reference));
}
new DefaultTestGroup(parser.getSerializer().serialize(parent.getReference()), parent.getReference(), entity);
return null;
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class TestSpaceFactory method getNewInstance.
@Override
TestSpace getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) {
EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"), DefaultTestSpace.TYPE, parent.getReference());
TestSpace space = (TestSpace) parent.getEntity(reference);
if (space == null) {
space = new DefaultTestSpace(reference, attributes.getValue("alt"), parent);
}
return space;
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class SheetDocumentDisplayer method display.
@Override
public XDOM display(DocumentModelBridge document, DocumentDisplayerParameters parameters) {
XDOM xdom = null;
if (isSheetExpected(document, parameters)) {
Map<String, Object> backupObjects = null;
EntityReference currentWikiReference = null;
try {
// it's not already there.
if (!modelBridge.isCurrentDocument(document)) {
backupObjects = modelBridge.pushDocumentInContext(document);
currentWikiReference = modelContext.getCurrentEntityReference();
modelContext.setCurrentEntityReference(document.getDocumentReference().getWikiReference());
}
xdom = maybeDisplayWithSheet(document, parameters);
} finally {
if (backupObjects != null) {
documentAccessBridge.popDocumentFromContext(backupObjects);
modelContext.setCurrentEntityReference(currentWikiReference);
}
}
}
// isolating the execution context is needed due to the way #isSheetExpected() checks for current document.
return xdom != null ? xdom : documentDisplayer.display(document, parameters);
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class TestAccessRuleFactory method getNewInstance.
@Override
TestAccessRule getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes) {
EntityReference userRef = parser.getResolver().resolve(attributes.getValue("name"), DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, parent.getReference().getRoot()));
Boolean allow = name.startsWith("allow");
String type = attributes.getValue("type");
String user = parser.getSerializer().serialize(userRef);
Boolean isUser = name.endsWith("User");
if (type != null) {
Right right = Right.toRight(type);
new DefaultTestAccessRule(user, userRef, right, allow, isUser, parent);
} else {
EntityType parentType = parent.getType();
if (parentType == EntityType.WIKI && ((TestWiki) parent).isMainWiki()) {
// Null here means root (or farm)
parentType = null;
}
for (Right right : Right.getEnabledRights(parentType)) {
if (right != Right.CREATOR) {
new DefaultTestAccessRule(user, userRef, right, allow, isUser, parent);
}
}
}
return null;
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class StandardExtendedURLResourceTypeResolver method registerEntityResourceReferenceResolver.
private void registerEntityResourceReferenceResolver(String registrationHint, Class<? extends ResourceReferenceResolver<ExtendedURL>> registrationImplementation, String wikiExtractorHint) throws InitializationException {
DefaultComponentDescriptor<ResourceReferenceResolver<ExtendedURL>> resolverDescriptor = new DefaultComponentDescriptor<>();
resolverDescriptor.setImplementation(registrationImplementation);
resolverDescriptor.setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
String hint = computeHint(registrationHint);
resolverDescriptor.setRoleHint(hint);
resolverDescriptor.setRoleType(new DefaultParameterizedType(null, ResourceReferenceResolver.class, ExtendedURL.class));
// Register dependencies
DefaultComponentDependency<WikiReferenceExtractor> wikiReferenceExtractorDependency = new DefaultComponentDependency<>();
wikiReferenceExtractorDependency.setRoleType(WikiReferenceExtractor.class);
wikiReferenceExtractorDependency.setRoleHint(wikiExtractorHint);
wikiReferenceExtractorDependency.setName("wikiExtractor");
resolverDescriptor.addComponentDependency(wikiReferenceExtractorDependency);
DefaultComponentDependency<EntityReferenceResolver<EntityReference>> entityReferenceResolverDependency = new DefaultComponentDependency<>();
entityReferenceResolverDependency.setRoleType(new DefaultParameterizedType(null, EntityReferenceResolver.class, EntityReference.class));
entityReferenceResolverDependency.setName("defaultReferenceEntityReferenceResolver");
resolverDescriptor.addComponentDependency(entityReferenceResolverDependency);
DefaultComponentDependency<StandardURLConfiguration> standardURLConfigurationDependency = new DefaultComponentDependency<>();
standardURLConfigurationDependency.setRoleType(StandardURLConfiguration.class);
standardURLConfigurationDependency.setName("configuration");
resolverDescriptor.addComponentDependency(standardURLConfigurationDependency);
DefaultComponentDependency<EntityResourceActionLister> entityResourceActionListerDependency = new DefaultComponentDependency<>();
entityResourceActionListerDependency.setRoleType(EntityResourceActionLister.class);
entityResourceActionListerDependency.setName("entityResourceActionLister");
resolverDescriptor.addComponentDependency(entityResourceActionListerDependency);
try {
this.rootComponentManager.registerComponent(resolverDescriptor);
} catch (ComponentRepositoryException e) {
throw new InitializationException(String.format("Failed to dynamically register Resource Reference Resolver for hint [%s]", hint), e);
}
}
Aggregations